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

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

l = A("l")
h = B("h")
d = B("d")
b = A("b")
k = A("k")
m = A("m")
e = B("e")
a = B("a")

l.v = a
l.z = b
h.y = e
d.y = e
b.v = a
b.z = m
k.v = e
k.z = b
m.v = d
m.z = b
e.y = a
a.y = d
assert k.v.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: A = None
        self.txt = txt

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

l = A("l")
h = B("h")
d = B("d")
b = A("b")
k = A("k")
m = A("m")
e = B("e")
a = B("a")

l.v = a
l.z = b
h.y = e
d.y = e
b.v = a
b.z = m
k.v = e
k.z = b
m.v = d
m.z = b
e.y = a
a.y = d
assert k.v.y.y.y.y.txt == "a"