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

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

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

e.z = k
n.w = d
n.u = d
k.z = e
d.w = n
d.u = n
assert k.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

e.z = k
n.w = d
n.u = d
k.z = e
d.w = n
d.u = n
assert k.z.z.z.txt == "e"