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

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

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

c = A("c")
a = B("a")
f = C("f")
e = C("e")
n = B("n")
g = C("g")
j = B("j")
l = B("l")
h = A("h")
m = C("m")

c.p = m
c.r = f
c.s = h
a.r = n
f.u = j
e.u = l
n.r = l
g.u = j
j.r = l
l.r = n
h.p = g
h.r = f
h.s = c
m.u = n
assert m.u.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: C = None
        self.s: A = None
        self.txt = txt

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

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

c = A("c")
a = B("a")
f = C("f")
e = C("e")
n = B("n")
g = C("g")
j = B("j")
l = B("l")
h = A("h")
m = C("m")

c.p = m
c.r = f
c.s = h
a.r = n
f.u = j
e.u = l
n.r = l
g.u = j
j.r = l
l.r = n
h.p = g
h.r = f
h.s = c
m.u = n
assert m.u.r.r.r.r.r.txt == "l"