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

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

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

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

e = A("e")
i = B("i")
b = C("b")
m = D("m")
f = B("f")

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

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

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

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

e = A("e")
i = B("i")
b = C("b")
m = D("m")
f = B("f")

e.x = b
e.u = b
i.z = e
i.o = e
i.r = f
b.t = f
b.u = f
m.o = b
f.z = e
f.o = e
f.r = i
assert i.o.x.t.z.u.txt == "b"