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.w: A = None
        self.txt = txt

l = A("l")
f = B("f")
i = A("i")
e = A("e")
n = A("n")

l.w = n
f.t = l
f.w = e
i.w = l
e.w = n
n.w = e
assert e.w.w.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.w: A = None
        self.txt = txt

l = A("l")
f = B("f")
i = A("i")
e = A("e")
n = A("n")

l.w = n
f.t = l
f.w = e
i.w = l
e.w = n
n.w = e
assert e.w.w.w.w.w.txt == "n"