Opening a Restaurant

No attempts yetTime limit5sMemory limit128 MB

Problem

You want to open a new restaurant. The city is an M×MM \times M grid. Every road is either vertical or horizontal, and the roads in each direction are numbered from 00 to M1M-1. Every restaurant sits at an intersection, and an intersection is written as a coordinate (x,y)(x, y), the pair (vertical road number, horizontal road number). The distance between two intersections (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is x1x2+y1y2|x_1 - x_2| + |y_1 - y_2|.

The city has two large apartment buildings AA and BB that lie on the same horizontal road (that is, they share the same yy coordinate). Both apartments already have a restaurant.

Because the residents of the two apartments meet often, you want to place the new restaurant somewhere between them. However, once the existing restaurants and rent are taken into account, the exact midpoint is not always best. So you look for a "good place" defined as follows, where dist(p,q)\text{dist}(p, q) is the distance between pp and qq.

An intersection pp is a "good place" if, for every existing restaurant qq, dist(p,A)<dist(q,A)\text{dist}(p, A) < \text{dist}(q, A) or dist(p,B)<dist(q,B)\text{dist}(p, B) < \text{dist}(q, B). In other words, pp is not a good place if there is any restaurant qq that satisfies dist(p,A)dist(q,A)\text{dist}(p, A) \ge \text{dist}(q, A) and dist(p,B)dist(q,B)\text{dist}(p, B) \ge \text{dist}(q, B) at the same time.

The restaurants qq that are compared include the ones at the two apartments AA and BB.

For example, consider an 11×1111 \times 11 city with apartments A=(0,5)A = (0, 5) and B=(10,5)B = (10, 5).

  • (7,4)(7, 4) is a good place.
  • p=(4,6)p = (4, 6) is not a good place because of the restaurant q=(3,5)q = (3, 5) (here dist(p,A)=5dist(q,A)=3\text{dist}(p, A) = 5 \ge \text{dist}(q, A) = 3 and dist(p,B)=7dist(q,B)=7\text{dist}(p, B) = 7 \ge \text{dist}(q, B) = 7).
  • (0,0)(0, 0) is not a good place because of the restaurant at apartment A=(0,5)A = (0, 5).

Given the positions of the existing restaurants, count how many of the M×MM \times M intersections of the city are good places.

Input

The first line contains the number of test cases TT. For each test case, the first line contains the city size MM and the number of restaurants NN (2M600002 \le M \le 60000, 2N500002 \le N \le 50000). Each of the next NN lines contains the coordinates xix_i, yiy_i of a restaurant (0xi,yi<M0 \le x_i, y_i < M).

No two restaurants share the same coordinates. Apartment AA is at the first restaurant and apartment BB is at the second restaurant, and AA and BB lie on the same horizontal road.

Output

For each test case, print the number of good places on its own line.