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

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

e = A("e")
k = B("k")
n = B("n")
a = B("a")
b = B("b")
g = A("g")
i = B("i")
m = B("m")
d = A("d")

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

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

e = A("e")
k = B("k")
n = B("n")
a = B("a")
b = B("b")
g = A("g")
i = B("i")
m = B("m")
d = A("d")

e.z = g
e.w = n
k.z = g
k.y = g
n.z = g
n.y = e
a.z = g
a.y = g
b.z = g
b.y = g
g.z = e
g.w = m
i.z = g
i.y = e
m.z = g
m.y = e
d.z = e
d.w = n
assert a.z.z.z.z.w.y.w.y.txt == "e"