var year,month,day,a,b,c,d,e,f,g: integer;
begin
readln(year);
a := year mod 4;
b := year mod 7;
c := year mod 19;
d := ( 19 * c + 15 ) mod 30;
e := ( 2 * a + 4 * b - d + 34 ) mod 7;
f := 3 + (d + e + 21) div 31;
g := ( d + e + 21 ) mod 31;
month := f;
day := g + 1;
writeln(day,' ',month);
end.