Calendar

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Handy Smurf created his newest invention: nanobot calendar.  It obviously consists of nanobots showing current date. Every day in order to switch current date they have to perform a cyclic rotation by kk places (so that nanobot that was initially at position ii is now at position (i+k)modn(i+k) \bmod n, nanobots are indexed from 00).  However, nanobots can only understand one command: reverse lrl r which reverses positions of all nanobots at positions between ll and rr (so that nanobot that was initially at position ll is now at rr, the one that was at l+1l+1 is now at r1r-1 and so on).  Help Handy write an algorithm for updating the date with minimum number of commands issued.

입력

First and only line of input contains two integers nn and kk (1n1091 \leq n \leq 10^9, 0k<n0 \leq k < n), specifying the number of nanobots and number of places to rotate.

출력

First line of output should contain integer mm -- the number of reverse commands used. On each of the next mm lines output two integers aa and bb (0ab<n0 \leq a \leq b < n) which means that the next command is reverse aba b.