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

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

m = A("m")
h = B("h")
i = B("i")
f = A("f")
b = B("b")
e = A("e")
k = B("k")
d = A("d")
a = B("a")
l = B("l")

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

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

m = A("m")
h = B("h")
i = B("i")
f = A("f")
b = B("b")
e = A("e")
k = B("k")
d = A("d")
a = B("a")
l = B("l")

m.z = b
m.y = h
h.p = l
h.w = d
i.p = a
i.w = f
f.z = l
f.y = k
b.p = i
b.w = m
e.z = i
e.y = k
k.p = i
k.w = m
d.z = l
d.y = i
a.p = l
a.w = e
l.p = i
l.w = d
assert m.z.p.w.y.p.p.w.z.p.txt == "a"