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.o: A = None
        self.txt = txt

d = A("d")
b = B("b")
c = A("c")
i = B("i")
l = B("l")
j = B("j")
m = B("m")
e = B("e")
n = B("n")
f = A("f")

d.o = j
d.v = i
b.o = f
c.o = j
c.v = n
i.o = d
l.o = d
j.o = c
m.o = d
e.o = d
n.o = f
f.o = e
f.v = i
assert m.o.o.o.v.o.v.o.v.o.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.o: A = None
        self.txt = txt

d = A("d")
b = B("b")
c = A("c")
i = B("i")
l = B("l")
j = B("j")
m = B("m")
e = B("e")
n = B("n")
f = A("f")

d.o = j
d.v = i
b.o = f
c.o = j
c.v = n
i.o = d
l.o = d
j.o = c
m.o = d
e.o = d
n.o = f
f.o = e
f.v = i
assert m.o.o.o.v.o.v.o.v.o.txt == "d"