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

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

b = A("b")
n = B("n")
i = A("i")
f = A("f")
k = A("k")
m = B("m")

b.v = k
n.o = m
n.t = i
i.v = f
f.v = b
k.v = i
m.o = n
m.t = k
assert m.o.o.o.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

b = A("b")
n = B("n")
i = A("i")
f = A("f")
k = A("k")
m = B("m")

b.v = k
n.o = m
n.t = i
i.v = f
f.v = b
k.v = i
m.o = n
m.t = k
assert m.o.o.o.t.v.txt == "f"