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

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

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

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

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

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

l.v = a
d.w = m
d.z = i
i.v = a
a.w = d
a.z = h
j.v = d
h.v = m
m.w = d
m.z = j
assert m.w.z.v.w.z.v.z.txt == "h"