human
Give me a Python program to compute the maximum value that x can attain if you choose the n - k chords optimally given the following:
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):


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...
The above is tricky. Write me a correct solution in PYTHON3.
assistant
#Here is Python program to compute the maximum value that x can attain if you choose the n - k chords optimally.

from math import *
from decimal import *
from decimal import Decimal as D
from string import ascii_lowercase as lc
from string import ascii_uppercase as uc
from itertools import *
from itertools import permutations as perm
from itertools import product as prod
from sys import *
ip = input
ra = lambda: list(map(int, input().split()))
ri = lambda: int(input())
rd = lambda: map(int, input().split())
MOD = 10 ** 9 + 7
MOD2 = 998244353
maxn = 10 ** 6 + 10
N = 10 ** 5 + 10
N2 = 2 * 10 ** 5
getcontext().prec = 20
def debug(*a):
    stderr.write(' '.join(map(str, a)) + '\n')
def fp(x, p, m):
    r = 1
    while p:
        if p % 2:
            r = r * x % m
            p -= 1
        else:
            x = x * x % m
            p //= 2
    return r
def fact(x, m):
    r = 1
    for i in range(2, x + 1):
        r = r * i % m
    return r
def C(n, k, m):
    return fact(n, m) * fp(fact(n - k, m), m - 2, m) % m * fp(fact(k, m), m - 2, m) % m
class SegmentTree:
    def f(self, a, b):
        return a + b
    def __init__(self, n, a):
        self.tree = [0] * (2 * n)
        self.n = n
        for i in range(n):
            self.tree[n + i] = a[i]
        for i in range(n - 1, 0, -1):
            self.tree[i] = self.f(self.tree[2 * i], self.tree[2 * i + 1])
    def q(self, l, r):
        l += self.n
        r += self.n
        res = 0
        while r > 1:
            if l % 2:
                res = self.f(res, self.tree[l]) 
                l += 1
            if r % 2:
                r -= 1
                res = self.f(res, self.tree[r])
            r //= 2
            l //= 2
        return res
    def u(self, index, value):
        index += self.n
        self.tree[index] = value
        index //= 2
        while index > 0:
            self.tree[index] = self.f(self.tree[2 * index], self.tree[2 * index + 1])
            index //= 2
def z_function(s):
    l, r, n = 0, 0, len(s)
    z = [0] * n
    z[0] = 0
    for i in range(1, n):
        if r >= i: z[i] = min(z[i - l], r - i + 1)
        while z[i] + i < n and...