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

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

m = A("m")
l = B("l")
k = A("k")
d = B("d")
e = A("e")
i = B("i")
c = A("c")
a = B("a")
b = B("b")
g = B("g")

m.v = k
l.z = c
l.w = k
k.v = e
d.z = k
d.w = m
e.v = k
i.z = m
i.w = m
c.v = k
a.z = k
a.w = m
b.z = m
b.w = e
g.z = m
g.w = k
assert c.v.v.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

m = A("m")
l = B("l")
k = A("k")
d = B("d")
e = A("e")
i = B("i")
c = A("c")
a = B("a")
b = B("b")
g = B("g")

m.v = k
l.z = c
l.w = k
k.v = e
d.z = k
d.w = m
e.v = k
i.z = m
i.w = m
c.v = k
a.z = k
a.w = m
b.z = m
b.w = e
g.z = m
g.w = k
assert c.v.v.v.v.v.v.v.v.v.txt == "k"