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

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

k = A("k")
m = B("m")
n = B("n")
c = A("c")
h = B("h")
g = B("g")
a = B("a")
j = A("j")
e = A("e")
d = B("d")

k.q = e
m.t = g
n.t = m
c.q = j
h.t = g
g.t = d
a.t = g
j.q = e
e.q = k
d.t = m
assert c.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

k = A("k")
m = B("m")
n = B("n")
c = A("c")
h = B("h")
g = B("g")
a = B("a")
j = A("j")
e = A("e")
d = B("d")

k.q = e
m.t = g
n.t = m
c.q = j
h.t = g
g.t = d
a.t = g
j.q = e
e.q = k
d.t = m
assert c.q.q.q.q.q.q.txt == "e"