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

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

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

m.z = e
m.s = a
h.v = a
h.r = g
i.v = g
i.r = a
k.v = a
k.r = a
a.z = g
a.s = m
g.z = a
g.s = e
b.v = m
b.r = g
e.z = g
e.s = g
n.v = m
n.r = a
d.v = m
d.r = e
assert b.v.z.s.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.s: A = None
        self.txt = txt

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

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

m.z = e
m.s = a
h.v = a
h.r = g
i.v = g
i.r = a
k.v = a
k.r = a
a.z = g
a.s = m
g.z = a
g.s = e
b.v = m
b.r = g
e.z = g
e.s = g
n.v = m
n.r = a
d.v = m
d.r = e
assert b.v.z.s.z.s.s.txt == "a"