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

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

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

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

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

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

i.p = n
i.o = j
g.p = c
j.p = b
j.o = b
b.p = j
b.o = j
k.p = c
n.p = j
n.o = j
c.p = g
e.p = k
l.p = c
h.p = b
h.o = i
assert b.p.p.p.txt == "j"