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

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

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

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

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

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

f.w = j
b.t = l
b.w = l
j.t = f
j.w = l
l.w = c
c.t = l
c.w = f
assert l.w.t.w.txt == "c"