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

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

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

l = A("l")
b = B("b")
f = C("f")
m = B("m")
a = A("a")
d = B("d")

l.x = f
l.r = f
l.z = d
b.u = a
b.s = f
b.q = f
f.o = a
m.u = l
m.s = f
m.q = f
a.x = f
a.r = f
a.z = b
d.u = a
d.s = f
d.q = f
assert m.q.o.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: C = None
        self.z: B = None
        self.txt = txt

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

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

l = A("l")
b = B("b")
f = C("f")
m = B("m")
a = A("a")
d = B("d")

l.x = f
l.r = f
l.z = d
b.u = a
b.s = f
b.q = f
f.o = a
m.u = l
m.s = f
m.q = f
a.x = f
a.r = f
a.z = b
d.u = a
d.s = f
d.q = f
assert m.q.o.z.u.txt == "a"