Hide

Problem C
Flæðasmíði

Languages en is

The summer is being used to do all kinds of maintenance and the utilities are no exception. There are n sources of water that have been found that need to be connected to m customers. Each source provides exactly 1L/s, and conveniently enough, the pipes can transport exactly 1L/s. 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 A to joint B 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 nmL/s. Care must be taken to make sure no pipe has to handle more than 1L/s. However, the joints can handle as much water as gets pumped into them. The sources are numbered 1,2,,n and the customers are numbered n+1,n+2,,n+m. The funding is quite limited, so the total number of joints can be at most 50000. The total number of pipes can also be at most 50000. Lastly, the customers can not have outputs.

Input

The input contains two integers n, the number of sources, and m, the number of customers, where 1nm1000.

Output

The first line of the output should contain the two integers V, the number of joints, sources and customers included, and E, the number of pipes between them. The new joints are then numbered n+m+1,n+m+2,,V. Then E lines follow, each describing one pipe. The i-th line should contain two integers Ai and Bi, representing that your solution includes a pipe from joint Ai to joint Bi.

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
Hide

Please log in to submit a solution to this problem

Log in