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

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

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

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

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

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

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