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.txt = txt

j = A("j")
f = B("f")
e = A("e")
c = B("c")

j.v = e
f.o = c
e.v = j
c.o = f
assert f.o.o.o.o.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.txt = txt

j = A("j")
f = B("f")
e = A("e")
c = B("c")

j.v = e
f.o = c
e.v = j
c.o = f
assert f.o.o.o.o.txt == "f"