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

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

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

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

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

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

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

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

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