#Lutece0383. Japan

Japan

Migrated from Lutece 383 Japan

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with NN cities on the East coast and MM cities on the West coast (1M100001\leq M \leq 10000, 1N100001\leq N\leq 10000). KK superhighways will be build.(1K10000001\leq K\leq 1000000) Cities on each coast are numbered 1,2,1, 2, \cdots from North to South. Each superhighway is straight line and connects city on the East coast with city of the West coast. The funding for the construction is guaranteed by ACM. A major portion of the sum is determined by the number of crossings between superhighways. At most two superhighways cross at one location. Write a program that calculates the number of the crossings between superhighways.

Input

The input file starts with TT - the number of test cases. Each test case starts with three numbers – NN, MM, KK. Each of the next KK lines contains two numbers – the numbers of cities connected by the superhighway. The first one is the number of the city on the East coast and second one is the number of the city of the West coast.

Output

For each test case write one line on the standard output: Test case (case number): (number of crossings)

Samples

1
3 4 4
1 4
2 3
3 2
3 1
Test case 1: 5

Note

The data used in this problem is unofficial data prepared by pfctgeorge. So any mistake here does not imply mistake in the offcial judge data.

Resources

Southeastern Europe 2006