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

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

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

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

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

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

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

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

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

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

i.o = c
i.t = m
m.q = i
m.p = d
m.o = l
m.z = a
a.u = l
a.t = d
a.z = m
d.y = m
c.o = i
c.t = m
l.u = a
l.t = d
l.z = m
assert l.u.u.u.txt == "a"