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

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

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

l = A("l")
c = B("c")
d = C("d")
e = C("e")
b = A("b")
a = B("a")

l.z = c
l.o = d
c.u = e
d.u = l
d.x = e
d.y = a
e.u = b
e.x = d
e.y = c
b.z = a
b.o = e
a.u = d
assert e.x.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: C = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
d = C("d")
e = C("e")
b = A("b")
a = B("a")

l.z = c
l.o = d
c.u = e
d.u = l
d.x = e
d.y = a
e.u = b
e.x = d
e.y = c
b.z = a
b.o = e
a.u = d
assert e.x.y.u.txt == "d"