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

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

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

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

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

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

b.w = j
b.s = j
f.w = j
f.v = b
j.w = f
j.v = b
assert j.v.w.w.txt == "f"