class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: B = 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.x: A = None
        self.txt = txt

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

e = A("e")
i = B("i")
b = C("b")
d = D("d")

e.x = i
e.o = i
i.u = b
b.x = e
d.z = e
d.s = b
assert d.s.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: B = 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.x: A = None
        self.txt = txt

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

e = A("e")
i = B("i")
b = C("b")
d = D("d")

e.x = i
e.o = i
i.u = b
b.x = e
d.z = e
d.s = b
assert d.s.x.o.txt == "i"