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

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

k = A("k")
h = B("h")
l = B("l")
d = A("d")
a = B("a")
i = A("i")
j = B("j")
f = A("f")
g = B("g")
m = B("m")

k.v = l
k.r = m
h.z = f
h.w = d
l.z = k
l.w = i
d.v = g
d.r = h
a.z = i
a.w = i
i.v = a
i.r = m
j.z = d
j.w = d
f.v = l
f.r = m
g.z = f
g.w = k
m.z = i
m.w = i
assert f.v.z.r.z.v.w.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

k = A("k")
h = B("h")
l = B("l")
d = A("d")
a = B("a")
i = A("i")
j = B("j")
f = A("f")
g = B("g")
m = B("m")

k.v = l
k.r = m
h.z = f
h.w = d
l.z = k
l.w = i
d.v = g
d.r = h
a.z = i
a.w = i
i.v = a
i.r = m
j.z = d
j.w = d
f.v = l
f.r = m
g.z = f
g.w = k
m.z = i
m.w = i
assert f.v.z.r.z.v.w.v.z.v.txt == "a"