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

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

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

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

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

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

b.o = l
b.p = m
l.p = a
f.o = j
f.p = g
a.p = k
j.p = a
g.o = l
g.p = m
i.o = k
i.p = m
m.o = j
m.p = g
k.p = j
assert k.p.p.p.p.p.p.p.p.txt == "a"