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

e = A("e")
n = B("n")
k = B("k")
c = A("c")

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

e = A("e")
n = B("n")
k = B("k")
c = A("c")

e.w = c
n.y = e
n.x = e
k.y = e
k.x = c
c.w = e
assert e.w.w.w.w.txt == "e"