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

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

k = A("k")
e = B("e")
b = A("b")
j = A("j")
f = A("f")
c = A("c")
m = A("m")
d = B("d")
a = A("a")
g = B("g")

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

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

k = A("k")
e = B("e")
b = A("b")
j = A("j")
f = A("f")
c = A("c")
m = A("m")
d = B("d")
a = A("a")
g = B("g")

k.q = d
e.z = k
e.t = f
b.q = g
j.q = d
f.q = d
c.q = g
m.q = e
d.z = j
d.t = c
a.q = e
g.z = f
g.t = k
assert m.q.z.q.z.q.t.q.t.txt == "k"