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

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

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

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

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

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

b.z = f
c.q = n
e.z = j
j.q = f
m.q = f
n.q = f
g.z = f
a.z = j
f.q = n
assert a.z.q.q.q.q.q.q.txt == "n"