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

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: B = None
        self.p: B = None
        self.txt = txt

c = A("c")
a = B("a")
d = C("d")
e = D("e")
i = B("i")

c.y = d
c.o = d
c.u = i
c.z = a
a.t = c
d.w = e
e.q = c
e.r = i
e.p = i
i.t = c
assert a.t.u.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.o: C = None
        self.u: B = None
        self.z: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: B = None
        self.p: B = None
        self.txt = txt

c = A("c")
a = B("a")
d = C("d")
e = D("e")
i = B("i")

c.y = d
c.o = d
c.u = i
c.z = a
a.t = c
d.w = e
e.q = c
e.r = i
e.p = i
i.t = c
assert a.t.u.t.u.t.txt == "c"