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

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

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

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

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

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

d.v = i
l.z = g
l.y = e
k.z = h
k.y = e
h.z = g
h.y = e
n.z = g
n.y = d
i.z = h
i.y = e
f.z = h
f.y = e
g.z = n
g.y = d
e.v = n
assert n.z.z.z.txt == "g"