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")
i = B("i")
j = A("j")
k = B("k")

l.w = k
i.w = l
j.w = k
k.w = j
assert i.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")
i = B("i")
j = A("j")
k = B("k")

l.w = k
i.w = l
j.w = k
k.w = j
assert i.w.w.w.w.txt == "k"