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

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

n = A("n")
h = B("h")
d = B("d")
i = A("i")
k = A("k")
a = B("a")
g = A("g")
l = A("l")

n.v = d
n.s = g
h.z = g
h.y = a
d.z = n
d.y = h
i.v = d
i.s = n
k.v = a
k.s = n
a.z = n
a.y = h
g.v = a
g.s = i
l.v = d
l.s = n
assert l.s.s.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: A = None
        self.txt = txt

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

n = A("n")
h = B("h")
d = B("d")
i = A("i")
k = A("k")
a = B("a")
g = A("g")
l = A("l")

n.v = d
n.s = g
h.z = g
h.y = a
d.z = n
d.y = h
i.v = d
i.s = n
k.v = a
k.s = n
a.z = n
a.y = h
g.v = a
g.s = i
l.v = d
l.s = n
assert l.s.s.v.z.v.txt == "d"