407885: GYM102916 I Chess Tournament

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Chess Tournamenttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Alex organizes a chess tournament in his company. The tournament is a round-robin tournament of $$$n$$$ people, and each pair of players will face each other exactly once.

The problem is, there are only $$$k$$$ chess boards in the office ($$$k \le \frac{n}{2}$$$). So only $$$k$$$ games can be played at the same time. Let's call $$$g$$$ games, being simultaneously played by $$$2g$$$ distinct players, where $$$1 \le g \le k$$$, a round.

Your task is to help Alex to set a schedule with a minimal number of rounds.

Input

The input contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200, 1 \le k \le \frac{n}{2}$$$) — the number of players and the number of chess boards.

Output

In the first line output an integer $$$r$$$ — the number of rounds.

Then output $$$r$$$ sections, describing rounds. In the first line of each section, output an integer $$$g$$$ ($$$1 \le g \le k$$$) — the number of games in this round. Then output $$$g$$$ lines with two integers each — the pairs of players that will play in this round. All these $$$2g$$$ integers must be distinct integers from $$$1$$$ to $$$n$$$.

If there are several possible solutions, output any of them.

ExamplesInput
4 2
Output
3
2
2 3
1 4
2
2 4
3 1
2
1 2
3 4
Input
5 2
Output
5
2
4 1
2 3
2
1 5
4 2
2
2 5
4 3
2
3 5
2 1
2
5 4
3 1
Input
6 2
Output
8
2
3 2
6 4
2
5 1
4 3
2
6 1
2 5
2
1 3
5 6
2
2 4
5 3
2
4 1
2 6
2
6 3
5 4
1
2 1

加入题单

上一题 下一题 算法标签: