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

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

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

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

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

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

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