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

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

a = A("a")
f = B("f")
l = B("l")
b = A("b")

a.w = b
f.t = b
l.t = b
b.w = a
assert f.t.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

a = A("a")
f = B("f")
l = B("l")
b = A("b")

a.w = b
f.t = b
l.t = b
b.w = a
assert f.t.w.w.w.txt == "a"