The summer is being used to do all kinds of maintenance and
the utilities are no exception. There are sources of water that have been
found that need to be connected to customers. Each source provides
exactly ,
and conveniently enough, the pipes can transport exactly
. But all
customers must receive an equal amount of water, otherwise
people will get upset which is no good. In order to balance the
flow, we can connect the pipes to special joints. Each joint
can have up to two inputs and up to two outputs. For each
joint, the flow coming into it is always equal to the flow
going out of it. Additionally, the joints make sure that, if
they have two outputs, the flow out of the two outputs is
equal. The pipes are also equipped with valves so if one goes
from joint to joint
water will only flow
in that direction and not back. Now a plan has to be made
regarding how to connect joints and pipes so each customer gets
. Care must be taken to make sure no pipe
has to handle more than . However, the joints can handle as much
water as gets pumped into them. The sources are numbered
and the
customers are numbered . The funding is quite limited, so
the total number of joints can be at most . The total number of pipes
can also be at most . Lastly, the customers can not have outputs.
Input
The input contains two integers , the number of sources, and
, the number of
customers, where .
Output
The first line of the output should contain the two integers
, the number of joints,
sources and customers included, and , the number of pipes between them.
The new joints are then numbered .
Then lines follow,
each describing one pipe. The -th line should contain two
integers and
, representing that
your solution includes a pipe from joint to joint .
If there are multiple solutions, you may output any of
them.
Sample Input 1 |
Sample Output 1 |
1 2
|
3 2
1 2
1 3
|
Sample Input 2 |
Sample Output 2 |
1 5
|
11 12
1 7
1 8
7 1
7 9
8 10
8 11
9 1
9 2
10 3
10 4
11 5
11 6
|
Sample Input 3 |
Sample Output 3 |
3 5
|
15 19
1 9
1 8
2 7
2 6
3 5
3 4
9 10
9 11
10 12
10 15
11 13
11 14
12 15
12 4
13 5
13 6
14 7
14 8
15 9
|