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

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

c = A("c")
i = B("i")
e = A("e")
a = A("a")
n = A("n")
g = A("g")
m = B("m")
k = A("k")
j = B("j")

c.r = n
c.z = k
i.v = n
i.p = m
e.r = g
e.z = c
a.r = k
a.z = k
n.r = a
n.z = k
g.r = e
g.z = a
m.v = n
m.p = j
k.r = e
k.z = a
j.v = k
j.p = i
assert j.v.z.z.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: A = None
        self.txt = txt

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

c = A("c")
i = B("i")
e = A("e")
a = A("a")
n = A("n")
g = A("g")
m = B("m")
k = A("k")
j = B("j")

c.r = n
c.z = k
i.v = n
i.p = m
e.r = g
e.z = c
a.r = k
a.z = k
n.r = a
n.z = k
g.r = e
g.z = a
m.v = n
m.p = j
k.r = e
k.z = a
j.v = k
j.p = i
assert j.v.z.z.r.r.txt == "g"