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

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

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

l = A("l")
e = B("e")
f = C("f")
d = C("d")
b = A("b")

l.u = d
l.z = f
e.t = l
e.x = b
e.o = b
f.r = d
f.o = d
f.p = e
d.r = f
d.o = f
d.p = e
b.u = d
b.z = f
assert d.o.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.txt = txt

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

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

l = A("l")
e = B("e")
f = C("f")
d = C("d")
b = A("b")

l.u = d
l.z = f
e.t = l
e.x = b
e.o = b
f.r = d
f.o = d
f.p = e
d.r = f
d.o = f
d.p = e
b.u = d
b.z = f
assert d.o.r.p.txt == "e"