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

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

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

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

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

n.q = a
n.y = d
i.u = m
k.o = i
c.z = e
m.u = i
d.q = a
d.y = n
a.o = i
e.z = c
assert a.o.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: A = None
        self.txt = txt

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

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

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

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

n.q = a
n.y = d
i.u = m
k.o = i
c.z = e
m.u = i
d.q = a
d.y = n
a.o = i
e.z = c
assert a.o.u.u.u.u.u.u.txt == "i"