Larry the magical panda got bored of playing with his number game, and now he is playing with bamboo sticks instead! Each stick has a non-zero integer length and can be classified as either a horizontal or vertical line on a coordinate plane. A horizontal stick has a left endpoint at
Larry then notices that his current arrangement of sticks can form rectangles! More precisely, a selection of
Constraints
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line contains two integers
The next
The next
Output Specification
Output the number of rectangles that can be formed on a single line.
Sample Input 1
2 2
2 -1 3
0 -1 3
1 -2 4
2 -2 4
Sample Output 1
1
Sample Input 2
4 3
2 0 6
-1 1 6
-1 -3 3
1 2 4
0 -2 4
3 -2 6
6 -1 2
Sample Output 2
2
Explanation for Sample Output 2
The two rectangles (denoted by bottom left and top right corner) are
Sample Input 3
4 4
2 0 2
2 0 2
0 0 2
0 0 2
0 0 2
0 0 2
2 0 2
2 0 2
Sample Output 3
16
Comments