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

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

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

k.w = n
l.y = k
l.o = n
a.y = k
a.o = n
e.y = n
e.o = k
n.w = k
assert a.y.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.y: A = None
        self.o: A = None
        self.txt = txt

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

k.w = n
l.y = k
l.o = n
a.y = k
a.o = n
e.y = n
e.o = k
n.w = k
assert a.y.w.w.w.w.txt == "k"