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

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

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

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

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

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

k.s = n
k.v = n
i.w = n
i.z = k
n.s = k
n.v = k
d.w = n
d.z = n
assert n.s.v.v.v.txt == "n"