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

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

k = A("k")
n = B("n")
f = A("f")
m = B("m")
i = A("i")
e = A("e")
d = A("d")

k.z = m
k.w = n
n.y = k
n.o = m
f.z = m
f.w = m
m.y = e
m.o = n
i.z = n
i.w = m
e.z = m
e.w = n
d.z = n
d.w = m
assert k.z.y.z.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: B = None
        self.txt = txt

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

k = A("k")
n = B("n")
f = A("f")
m = B("m")
i = A("i")
e = A("e")
d = A("d")

k.z = m
k.w = n
n.y = k
n.o = m
f.z = m
f.w = m
m.y = e
m.o = n
i.z = n
i.w = m
e.z = m
e.w = n
d.z = n
d.w = m
assert k.z.y.z.y.w.txt == "n"