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

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

a = A("a")
n = B("n")
j = B("j")
f = B("f")
k = B("k")
i = B("i")
c = A("c")
b = B("b")
h = A("h")
e = B("e")

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

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

a = A("a")
n = B("n")
j = B("j")
f = B("f")
k = B("k")
i = B("i")
c = A("c")
b = B("b")
h = A("h")
e = B("e")

a.o = n
n.v = c
j.v = h
f.v = h
k.v = c
i.v = h
c.o = b
b.v = h
h.o = e
e.v = h
assert i.v.o.v.o.v.txt == "h"