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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.z: B = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.z: B = None
        self.txt = txt

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

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