class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: C = None
        self.x: A = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
l = C("l")
e = C("e")
a = B("a")
c = A("c")
j = C("j")
m = B("m")

f.z = j
f.q = e
f.x = c
g.u = a
l.u = c
e.u = f
a.u = g
c.z = l
c.q = l
c.x = f
j.u = c
m.u = g
assert m.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: C = None
        self.x: A = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
l = C("l")
e = C("e")
a = B("a")
c = A("c")
j = C("j")
m = B("m")

f.z = j
f.q = e
f.x = c
g.u = a
l.u = c
e.u = f
a.u = g
c.z = l
c.q = l
c.x = f
j.u = c
m.u = g
assert m.u.u.u.u.txt == "a"