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

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

j = A("j")
l = B("l")
k = B("k")
n = A("n")
h = B("h")
c = A("c")
a = B("a")
e = B("e")
d = A("d")
f = B("f")

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

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

j = A("j")
l = B("l")
k = B("k")
n = A("n")
h = B("h")
c = A("c")
a = B("a")
e = B("e")
d = A("d")
f = B("f")

j.p = n
l.v = f
l.o = a
k.v = l
k.o = a
n.p = c
h.v = f
h.o = e
c.p = n
a.v = h
a.o = f
e.v = f
e.o = f
d.p = n
f.v = e
f.o = h
assert a.v.o.v.o.v.o.o.o.txt == "f"