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

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

e = A("e")
h = B("h")
b = B("b")
l = B("l")
d = A("d")
a = A("a")
f = A("f")
g = B("g")
n = B("n")

e.z = a
e.v = d
h.v = l
h.z = f
b.v = l
b.z = f
l.v = n
l.z = d
d.z = f
d.v = a
a.z = f
a.v = d
f.z = e
f.v = e
g.v = l
g.z = a
n.v = h
n.z = a
assert a.v.z.v.v.v.z.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: A = None
        self.txt = txt

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

e = A("e")
h = B("h")
b = B("b")
l = B("l")
d = A("d")
a = A("a")
f = A("f")
g = B("g")
n = B("n")

e.z = a
e.v = d
h.v = l
h.z = f
b.v = l
b.z = f
l.v = n
l.z = d
d.z = f
d.v = a
a.z = f
a.v = d
f.z = e
f.v = e
g.v = l
g.z = a
n.v = h
n.z = a
assert a.v.z.v.v.v.z.z.v.txt == "d"