eolymp
bolt
Try our new interface for solving problems
Problems

Build More Roads!

Build More Roads!

The king of Talkland is planning to build new roads in the kingdom. Indeed, the old roads are all muddy and full of ruts. The new roads will be paved with yellow bricks and shine on the sun. Of course, all roads will be two-way. There are \textbf{n} cities in Talkland and the king wants to build as many roads as possible. However, he knows that if there are \textbf{r} cities, such that each pair of them is connected by a road, citizens of those communicate too much, so the risk of the revolution becomes too strong. Therefore he wants to build as many roads as possible, but in such way that no \textbf{r }cities are all pairwise connected. You, his transportation and educaction wizard, must help! \InputFile Input file contains \textbf{n} and \textbf{r} (\textbf{3} ≤ \textbf{n} ≤ \textbf{100}, \textbf{3} ≤ \textbf{r} ≤ \textbf{n}). \OutputFile On the first line of the output file output \textbf{m} --- the number of roads to build. Next \textbf{m} lines must contain the descriptions of the roads, for each road output the cities it must connect.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4 3
Output example #1
4
1 3
1 4
2 3
2 4
Source Russian Teams Training Sessions in Petrozavodsk, Summer 2004, Andrew Stankevich Contest 8, Thursday, August 26, 2004