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

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

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

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

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

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

j.u = a
j.w = b
a.v = j
a.t = j
b.u = a
b.w = j
assert j.w.w.u.txt == "a"