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

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

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

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

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

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

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

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

c.u = b
g.y = d
n.q = d
k.y = m
m.q = j
b.q = n
e.u = d
i.y = n
d.q = j
j.q = m
assert d.q.q.q.q.q.q.q.q.txt == "m"