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

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

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

b.o = i
d.t = j
d.v = i
c.o = j
f.o = j
i.o = c
l.t = j
l.v = b
m.t = i
m.v = i
a.t = j
a.v = j
j.o = c
assert d.t.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

b.o = i
d.t = j
d.v = i
c.o = j
f.o = j
i.o = c
l.t = j
l.v = b
m.t = i
m.v = i
a.t = j
a.v = j
j.o = c
assert d.t.o.o.o.o.o.o.txt == "j"