A Cycle of Points
There are n points on a plane, numbered from 1 to n. They form a directed cycle 1 → 2 → ... → n → 1. You need to perform the following operation several times: given the numbers of two points a and b, remove the part of the cycle starting with the point a and ending with the point b, and return it back in reversed order, so that part will start from b and end with a. Find the length of the final cycle.
Input
The first line contains two numbers n and m (3 ≤ n, m ≤ 100000). Next n lines contain two numbers x[i]
and y[i]
- coordinates of i-th point. Next m lines contain two numbers a[i]
and b[i]
- point numbers in i-th operation.
Output
Output the length of the final cycle with two digits after the decimal point.
Examples
Note
Initial cycle: 1 → 2 → 3 → 4 → 5 → 1
After the first operation: 1 → 5 → 3 → 4 → 2 → 1(part 5 → 1 → 2 is replaced with 2 → 1 → 5)
After the second operation: 1 → 2 → 4 → 3 → 5 → 1 (part 5 → 3 → 4 → 2 is replaced with 2 → 4 → 3 → 5)
After the third operation: 1 → 2 → 5 → 3 → 4 → 1