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

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

b = A("b")
f = B("f")
n = B("n")
a = A("a")
c = B("c")
h = B("h")
j = A("j")
l = B("l")

b.p = n
b.o = a
f.p = a
n.p = b
a.p = l
a.o = b
c.p = a
h.p = j
j.p = c
j.o = b
l.p = a
assert f.p.o.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: A = None
        self.txt = txt

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

b = A("b")
f = B("f")
n = B("n")
a = A("a")
c = B("c")
h = B("h")
j = A("j")
l = B("l")

b.p = n
b.o = a
f.p = a
n.p = b
a.p = l
a.o = b
c.p = a
h.p = j
j.p = c
j.o = b
l.p = a
assert f.p.o.p.p.p.p.p.p.txt == "b"