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

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

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

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

l = A("l")
j = B("j")
i = C("i")
e = D("e")
c = D("c")

l.t = e
j.u = l
i.w = j
e.x = c
e.z = c
e.t = l
c.x = e
c.z = e
c.t = l
assert c.x.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

l = A("l")
j = B("j")
i = C("i")
e = D("e")
c = D("c")

l.t = e
j.u = l
i.w = j
e.x = c
e.z = c
e.t = l
c.x = e
c.z = e
c.t = l
assert c.x.t.t.t.t.txt == "e"