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

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

j = A("j")
k = B("k")
d = B("d")
b = A("b")
a = B("a")
n = B("n")
i = B("i")
m = A("m")
g = B("g")

j.v = m
j.u = g
k.z = a
k.p = g
d.z = n
d.p = k
b.v = m
b.u = g
a.z = d
a.p = i
n.z = g
n.p = g
i.z = k
i.p = n
m.v = b
m.u = i
g.z = i
g.p = a
assert d.z.p.z.z.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: B = None
        self.txt = txt

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

j = A("j")
k = B("k")
d = B("d")
b = A("b")
a = B("a")
n = B("n")
i = B("i")
m = A("m")
g = B("g")

j.v = m
j.u = g
k.z = a
k.p = g
d.z = n
d.p = k
b.v = m
b.u = g
a.z = d
a.p = i
n.z = g
n.p = g
i.z = k
i.p = n
m.v = b
m.u = i
g.z = i
g.p = a
assert d.z.p.z.z.p.z.txt == "i"