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

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

l = A("l")
e = B("e")
n = A("n")
d = A("d")
k = B("k")

l.w = k
e.w = k
n.w = k
d.w = k
k.w = e
assert n.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: B = None
        self.txt = txt

l = A("l")
e = B("e")
n = A("n")
d = A("d")
k = B("k")

l.w = k
e.w = k
n.w = k
d.w = k
k.w = e
assert n.w.w.w.txt == "k"