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

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

b = A("b")
k = B("k")
l = A("l")
h = B("h")
n = B("n")
j = A("j")
c = B("c")
e = A("e")

b.z = j
k.q = b
l.z = e
h.q = l
n.q = j
j.z = l
c.q = l
e.z = b
assert c.q.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

b = A("b")
k = B("k")
l = A("l")
h = B("h")
n = B("n")
j = A("j")
c = B("c")
e = A("e")

b.z = j
k.q = b
l.z = e
h.q = l
n.q = j
j.z = l
c.q = l
e.z = b
assert c.q.z.z.z.z.z.z.z.txt == "j"