#include <bits/stdc++.h>
using namespace std;
int n, k, st[205], ed[205], mk[205];
inline bool judge(int x, int y) {
  return (st[x] < st[y] && st[y] < ed[x]) ^ (st[x] < ed[y] && ed[y] < ed[x]);
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    memset(mk, 0, sizeof(mk));
    for (int i = 1; i <= k; i++) {
      scanf("%d%d", st + i, ed + i), mk[st[i]] = mk[ed[i]] = 1;
      if (st[i] > ed[i]) swap(st[i], ed[i]);
    }
    int ans = 0;
    for (int i = 1; i <= k; i++) {
      int tmp = 0;
      for (int j = st[i]; j <= ed[i]; j++) tmp += (!mk[j]);
      ans += min(tmp, n * 2 - k * 2 - tmp);
      for (int j = i + 1; j <= k; j++) ans += judge(i, j);
    }
    printf("%d\n", ans + (n - k) * (n - k - 1) / 2);
  }
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

On a circle lie 2n distinct points, with the following property: however you choose 3 chords that connect 3 disjoint pairs of points, no point strictly inside the circle belongs to all 3 chords. The points are numbered 1,   2,   ...,   2n in clockwise order.

Initially, k chords connect k pairs of points, in such a way that all the 2k endpoints of these chords are distinct.

You want to draw n - k additional chords that connect the remaining 2(n - k) points (each point must be an endpoint of exactly one chord).

In the end, let x be the total number of intersections among all n chords. Compute the maximum value that x can attain if you choose the n - k chords optimally.

Note that the exact position of the 2n points is not relevant, as long as the property stated in the first paragraph holds.

Input

The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.

The first line of each test case contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ n) — half the number of points and the number of chords initially drawn.

Then k lines follow. The i-th of them contains two integers x_i and y_i (1 ≤ x_i,   y_i ≤ 2n, x_i ≠ y_i) — the endpoints of the i-th chord. It is guaranteed that the 2k numbers x_1,   y_1,   x_2,   y_2,   ...,   x_k,   y_k are all distinct.

Output

For each test case, output the maximum number of intersections that can be obtained by drawing n - k additional chords.

Example

Input


4
4 2
8 2
1 5
1 1
2 1
2 0
10 6
14 6
2 20
9 10
13 18
15 12
11 7


Output


4
0
1
14

Note

In the first test case, there are three ways to draw the 2 additional chords, shown below (black chords are the ones initially drawn, while red chords are the new ones):

<image>

We see that the third way gives the maximum number of intersections, namely 4.

In the second test case, there are no more chords to draw. Of course, with only one chord present there are no intersections.

In the third test case, we can make at most one intersection by drawing chords 1-3 and 2-4, as shown below:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k, st[205], ed[205], mk[205];
inline bool judge(int x, int y) {
  return (st[x] < st[y] && st[y] < ed[x]) ^ (st[x] < ed[y] && ed[y] < ed[x]);
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    memset(mk, 0, sizeof(mk));
    for (int i = 1; i <= k; i++) {
      scanf("%d%d", st + i, ed + i), mk[st[i]] = mk[ed[i]] = 1;
      if (st[i] > ed[i]) swap(st[i], ed[i]);
    }
    int ans = 0;
    for (int i = 1; i <= k; i++) {
      int tmp = 0;
      for (int j = st[i]; j <= ed[i]; j++) tmp += (!mk[j]);
      ans += min(tmp, n * 2 - k * 2 - tmp);
      for (int j = i + 1; j <= k; j++) ans += judge(i, j);
    }
    printf("%d\n", ans + (n - k) * (n - k - 1) / 2);
  }
  return 0;
}

```