H. Sparkle's Stage
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Recently, Sparkle has been interested in vehicles, so she has set up a number line and placed $$$N$$$ ($$$1 \le N \le 5000$$$) trucks with equal mass on it. The $$$i$$$-th truck is initially located at position $$$x_i$$$ ($$$1 \le x_i \le 10^9$$$) with velocity $$$v_i$$$ ($$$-10^9 \le v_i \le 10^9$$$). Since this is all a dream, when two trucks collide, they will not explode, but rather undergo a perfectly elastic collision, ie. if two trucks collide, their velocities will be swapped. Sparkle is now curious about the number of times the trucks will collide, and she wants you to find this number or tell her that there will be infinite collisions. Note that if $$$k$$$ trucks collide at the same time, then this will be counted as $$$\frac{k(k - 1)}{2}$$$ collisions.

Input

The first line contains a single integer $$$N$$$ ($$$1 \le N \le 5000$$$).

Each of the next $$$N$$$ lines contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i \le 10^9$$$, $$$-10^9 \le v_i \le 10^9$$$). It is guaranteed that all $$$x_i$$$ are distinct.

Output

Output a single integer denoting the total number of collisions or $$$-1$$$ if there will be infinite collisions.

Example
Input
2
1 1
2 -1
Output
1
Note

The two trucks will move towards each other and collide once before going into opposite directions and never colliding again.