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

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

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

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

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

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

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

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

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

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

i.r = l
i.u = e
m.p = c
e.t = j
c.t = e
c.z = e
c.p = l
j.r = c
j.u = e
l.t = e
l.z = e
l.p = c
assert l.z.t.u.txt == "e"