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

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

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

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

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

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

l.w = f
f.w = b
b.w = f
a.w = f
c.w = f
j.w = f
i.w = f
assert f.w.w.w.w.w.w.w.txt == "b"