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

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

i = A("i")
n = B("n")
m = A("m")
a = A("a")
l = A("l")
b = A("b")
k = A("k")

i.q = m
n.v = b
m.q = k
a.q = i
l.q = b
b.q = k
k.q = l
assert m.q.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.v: A = None
        self.txt = txt

i = A("i")
n = B("n")
m = A("m")
a = A("a")
l = A("l")
b = A("b")
k = A("k")

i.q = m
n.v = b
m.q = k
a.q = i
l.q = b
b.q = k
k.q = l
assert m.q.q.q.q.q.q.q.txt == "k"