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

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

b = A("b")
d = B("d")
a = A("a")
k = A("k")
f = B("f")
m = A("m")
c = A("c")

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

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

b = A("b")
d = B("d")
a = A("a")
k = A("k")
f = B("f")
m = A("m")
c = A("c")

b.v = m
b.o = d
d.t = a
a.v = b
a.o = d
k.v = a
k.o = f
f.t = b
m.v = a
m.o = d
c.v = a
c.o = f
assert f.t.o.t.o.txt == "d"