python3 - <<'PY' T=112 M=[(-2,5,-1),(-1,-4,3),(0,4,-3),(1,2,2),(2,-5,1),(-2,1,-4),(1,-4,-2),(2,3,-3)] def md(a,m): return a-(a//m)*m r=17