eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Build More Roads!

Build More Roads!

Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB

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 n cities in Talkland and the king wants to build as many roads as possible. However, he knows that if there are 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 r cities are all pairwise connected.

You, his transportation and educaction wizard, must help!

Вхідні дані

Input file contains n and r (3n100, 3rn).

Вихідні дані

On the first line of the output file output m — the number of roads to build. Next m lines must contain the descriptions of the roads, for each road output the cities it must connect.

Приклад

Вхідні дані #1
4 3
Вихідні дані #1
4
1 3
1 4
2 3
2 4
Джерело Russian Teams Training Sessions in Petrozavodsk, Summer 2004, Andrew Stankevich Contest 8, Thursday, August 26, 2004