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

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

n = A("n")
j = B("j")
a = B("a")
h = B("h")
l = A("l")
c = B("c")
i = B("i")
d = A("d")
m = B("m")
f = A("f")

n.z = h
n.v = f
j.z = d
j.s = f
a.z = f
a.s = d
h.z = l
h.s = n
l.z = h
l.v = n
c.z = l
c.s = l
i.z = f
i.s = f
d.z = i
d.v = n
m.z = l
m.s = d
f.z = a
f.v = d
assert m.z.z.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: A = None
        self.txt = txt

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

n = A("n")
j = B("j")
a = B("a")
h = B("h")
l = A("l")
c = B("c")
i = B("i")
d = A("d")
m = B("m")
f = A("f")

n.z = h
n.v = f
j.z = d
j.s = f
a.z = f
a.s = d
h.z = l
h.s = n
l.z = h
l.v = n
c.z = l
c.s = l
i.z = f
i.s = f
d.z = i
d.v = n
m.z = l
m.s = d
f.z = a
f.v = d
assert m.z.z.z.v.txt == "n"