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

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

k = A("k")
n = B("n")
c = B("c")
i = A("i")
d = A("d")
l = A("l")

k.z = i
n.w = l
c.w = i
i.z = k
d.z = i
l.z = d
assert l.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: A = None
        self.txt = txt

k = A("k")
n = B("n")
c = B("c")
i = A("i")
d = A("d")
l = A("l")

k.z = i
n.w = l
c.w = i
i.z = k
d.z = i
l.z = d
assert l.z.z.z.txt == "k"