class A:
    def __init__(self, txt: str):
        self.q: B = 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: A = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
n = B("n")
m = C("m")
e = D("e")
g = B("g")
k = B("k")
i = D("i")
b = D("b")

c.q = k
n.u = k
m.o = c
m.r = c
e.z = m
e.o = m
e.p = m
g.u = n
k.u = n
i.z = m
i.o = m
i.p = m
b.z = m
b.o = m
b.p = m
assert m.r.q.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = 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: A = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
n = B("n")
m = C("m")
e = D("e")
g = B("g")
k = B("k")
i = D("i")
b = D("b")

c.q = k
n.u = k
m.o = c
m.r = c
e.z = m
e.o = m
e.p = m
g.u = n
k.u = n
i.z = m
i.o = m
i.p = m
b.z = m
b.o = m
b.p = m
assert m.r.q.u.u.u.u.u.txt == "n"