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

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

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

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

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

c.t = i
a.x = d
a.o = k
k.t = a
d.s = e
d.u = k
d.z = c
e.t = c
i.t = e
assert i.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

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

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

c.t = i
a.x = d
a.o = k
k.t = a
d.s = e
d.u = k
d.z = c
e.t = c
i.t = e
assert i.t.t.t.t.txt == "e"