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

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

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

n = A("n")
i = B("i")
j = C("j")
h = C("h")
b = A("b")
f = A("f")
e = C("e")
m = B("m")
a = B("a")

n.z = i
i.r = h
j.v = e
j.s = h
j.p = b
h.v = j
h.s = j
h.p = f
b.z = i
f.z = i
e.v = h
e.s = h
e.p = f
m.r = e
a.r = e
assert n.z.r.v.p.z.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

n = A("n")
i = B("i")
j = C("j")
h = C("h")
b = A("b")
f = A("f")
e = C("e")
m = B("m")
a = B("a")

n.z = i
i.r = h
j.v = e
j.s = h
j.p = b
h.v = j
h.s = j
h.p = f
b.z = i
f.z = i
e.v = h
e.s = h
e.p = f
m.r = e
a.r = e
assert n.z.r.v.p.z.r.v.txt == "j"