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

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

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

f = A("f")
n = B("n")
j = C("j")
g = B("g")
h = B("h")
d = B("d")
i = C("i")
m = A("m")
k = A("k")
a = A("a")

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

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

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

f = A("f")
n = B("n")
j = C("j")
g = B("g")
h = B("h")
d = B("d")
i = C("i")
m = A("m")
k = A("k")
a = A("a")

f.s = g
n.s = j
n.y = j
j.v = n
j.r = k
j.p = m
g.s = j
g.y = j
h.s = j
h.y = i
d.s = i
d.y = i
i.v = h
i.r = m
i.p = f
m.s = h
k.s = h
a.s = h
assert d.y.p.s.y.r.s.y.r.txt == "m"