class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

c = A("c")
a = B("a")
m = C("m")
e = B("e")
g = A("g")
k = A("k")

c.o = g
c.r = k
a.w = m
a.u = g
m.y = a
e.w = m
e.u = c
g.o = c
g.r = k
k.o = c
k.r = c
assert a.u.o.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

c = A("c")
a = B("a")
m = C("m")
e = B("e")
g = A("g")
k = A("k")

c.o = g
c.r = k
a.w = m
a.u = g
m.y = a
e.w = m
e.u = c
g.o = c
g.r = k
k.o = c
k.r = c
assert a.u.o.r.r.txt == "c"