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

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

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

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

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

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

l.o = k
k.q = b
a.o = m
c.o = m
e.o = k
g.o = f
m.q = k
j.q = b
b.q = m
f.q = k
assert l.o.q.q.q.q.q.q.txt == "k"