There are $N$ robots who work for $Y$ days and on each day they
produce some toys .on some days a few robots are given rest.
So depending on the availability of robots owner has 
made a time table which decides which robots will work on 
the particular day.
Only contiguous robots must be selected as they can form 
a link of communication among themselves.
Initially, all robots have the capacity of one toy.
On each day capacity for the chosen robot is updated i.e
capacity = capacity $+$$ ($minimum capacity of given range % $1000000007)$ .
After calculating the minimum capacity of a given range, compute
it as modulo 1000000007 ($10^9 + 7$).
After $Y$ days find the minimum capacity of the $N$ robots and compute it as modulo 1000000007 ($10^9 + 7$).   

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Next Line contains a single integer N.
- Next Line contains a single integer Y.
- Next $Y$ lines contains l and r range of chosen robots .

-----Output:-----
For each testcase, output in a single line answer , the minimum capacity of the $N$ robots after $Y$ days and compute it as modulo 1000000007 ($10^9 + 7$) .

-----Constraints-----
- $1 \leq T \leq 100$
- $100 \leq N \leq 10^4$
- $200 \leq Y \leq 1000$
- $0<=l , r<=N-1$  , $l<=r$

-----Sample Input:-----
1
5
4
0 3
1 2
4 4
0 4

-----Sample Output:-----
4

-----EXPLANATION:-----
Initial capacity of the $5$ robots
1 1 1 1 1 
Minimum in range [0,3] = 1
Update the capacity in the range [0,3]
Now capacity becomes, 
Day 1 - 2 2 2 2 1
Similarly capacities changes for each day 
Day 2 - 2 4 4 2 1
Day 3 - 2 4 4 2 2
Day 4 - 4 6 6 4 4
so after 4 days minimum capacity is $4$.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'MAX = 100005\ntree = [0] * MAX; \nlazy = [0] * MAX;\n \ndef updateRangeUtil(si, ss, se, us, ue, diff) :\n    if (lazy[si] != 0) :\n        tree[si] += lazy[si];\n        if (ss != se) :\n            lazy[si * 2 + 1] += lazy[si];\n            lazy[si * 2 + 2] += lazy[si];\n        lazy[si] = 0;\n \n    if (ss > se or ss > ue or se < us) :\n        return; \n \n    if (ss >= us and se <= ue) :\n        tree[si] += diff;\n        if (ss != se) :\n            lazy[si * 2 + 1] += diff;\n            lazy[si * 2 + 2] += diff;\n        return; \n \n    mid = (ss + se) // 2;\n    updateRangeUtil(si * 2 + 1, ss,mid, us, ue, diff);\n    updateRangeUtil(si * 2 + 2, mid + 1,se, us, ue, diff);\n    tree[si] = min(tree[si * 2 + 1],tree[si * 2 + 2]); \n \ndef updateRange(n, us, ue, diff) : \n    updateRangeUtil(0, 0, n - 1, us, ue, diff); \n \ndef getSumUtil(ss, se, qs, qe, si) :\n    if (lazy[si] != 0) :\n        tree[si] += lazy[si];\n        if (ss != se) :\n            lazy[si * 2 + 1] += lazy[si];\n            lazy[si * 2 + 2] += lazy[si];\n        lazy[si] = 0;\n \n    if (ss > se or ss > qe or se < qs) :\n        return 10e9; \n \n    if (ss >= qs and se <= qe) :\n        return tree[si]; \n \n    mid = (ss + se) // 2; \n    return min(getSumUtil(ss, mid, qs, qe, 2 * si + 1),getSumUtil(mid + 1, se, qs, qe, 2 * si + 2)); \n \ndef getSum(n, qs, qe) : \n    if (qs < 0 or qe > n - 1 or qs > qe) :\n        #print("Invalid Input", end = "");\n        return -1;\n \n    return getSumUtil(0, n - 1, qs, qe, 0); \n \ndef constructSTUtil(arr, ss, se, si) : \n    if (ss > se) :\n        return;\n    if (ss == se) :\n        tree[si] = arr[ss];\n        return; \n    mid = (ss + se) // 2;\n    constructSTUtil(arr, ss, mid, si * 2 + 1);\n    constructSTUtil(arr, mid + 1, se, si * 2 + 2);\n    tree[si] = min(tree[si * 2 + 1], tree[si * 2 + 2]); \n \ndef constructST(arr, n) :\n    constructSTUtil(arr, 0, n - 1, 0); \n \n# Driver code \nfor _ in range(int(input())):\n    tree = [0] * MAX; \n    lazy = [0] * MAX;\n    n=int(input());\n    y=int(input());\n    arr=[1]*n;\n    constructST(arr, n);\n    for xyz in range(y):\n        l,r=list(map(int,input().split()));\n        updateRange(n, l, r, getSum(n, l, r)%1000000007);\n    print((getSum(n, 0, n-1)%1000000007));\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 2406209