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

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

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

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

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

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

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

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

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