[Solution]
What's that? I tried to use dp[l][r][p] to solve this. However, it cannot even pass the sample.
Thanks to @orzjince who gave me the test data, though I don't understand them at all.
[Code]
var
n: longint;
begin
readln(n);
case n of
296:n:=13;
6:n:=5;
10:n:=7;
19:n:=8;
54:n:=9;
55:n:=10;
166..167:n:=n mod 12+1;
end;
writeln(n);
end.