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

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

a = A("a")
b = B("b")
j = A("j")
e = B("e")
m = B("m")

a.o = j
a.v = m
b.v = a
j.o = a
j.v = e
e.v = j
m.v = a
assert j.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.v: B = None
        self.txt = txt

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

a = A("a")
b = B("b")
j = A("j")
e = B("e")
m = B("m")

a.o = j
a.v = m
b.v = a
j.o = a
j.v = e
e.v = j
m.v = a
assert j.o.o.o.txt == "a"