We all know that Share market is place where drastic change occurs within moments. So we have one Stockholder, Isabella, who wants to maximize her profit by selling her shares. She has $N$ shares of a Doofenshmirtz Corporation which is represented by $N$ different lines where each line contains two space separated integers $a_i$ , $b_i$ corresponding to initial and final values of the share prize. Isabella can sell any number of shares. But, she will sell those shares only if the following condition is satisfied - 
- for any pair $(i,j)$ of shares that she choses to sell, $a_i \leq a_j$  and $b_i < b_j$ must be satisfied. 
You need to tell Isabella the maximum number of Shares she can sell.

-----Input:-----
- First line will contain $T$, number of test cases. 
- Each test case has the following format:
- First line of each test case contain single integer $N$, the number of shares of Isabella.  
- Next $N$ lines of each test case contain two space separated integers $a_i$, $b_i$ (initial and final value of share prize respectively) for each $1 \leq i \leq N$.

-----Output:-----
For each test case output a single integer: the maximum number of shares that can be sold by Isabella.

-----Constraints-----
- $1 \leq T \leq 5$
- $1 \leq N \leq 10^5$
- $1 \leq a_i , b_i \leq 10^9 , for  each $1$ \leq $i$ \leq $N 

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

-----Sample Output:-----
$3$   

-----Explanation:-----
Here, Isabella decided to sell share 1, share 3 and share 4 as any two pair of 
chosen share hold the given condition.

```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 = '# Python program to find \r\n# length of longest \r\n# increasing subsequence \r\n# in O(n Log n) time \r\n\r\n# Binary search (note \r\n# boundaries in the caller) \r\n# A[] is ceilIndex \r\n# in the caller \r\ndef CeilIndex(A, l, r, key): \r\n\r\n\twhile (r - l > 1): \r\n\t\r\n\t\tm = l + (r - l)//2\r\n\t\tif (A[m] >= key): \r\n\t\t\tr = m \r\n\t\telse: \r\n\t\t\tl = m \r\n\treturn r \r\n\r\ndef LongestIncreasingSubsequenceLength(A, size): \r\n\r\n\t# Add boundary case, \r\n\t# when array size is one \r\n\r\n\ttailTable = [0 for i in range(size + 1)] \r\n\tlen = 0 # always points empty slot \r\n\r\n\ttailTable[0] = A[0] \r\n\tlen = 1\r\n\tfor i in range(1, size): \r\n\t\r\n\t\tif (A[i] < tailTable[0]): \r\n\r\n\t\t\t# new smallest value \r\n\t\t\ttailTable[0] = A[i] \r\n\r\n\t\telif (A[i] > tailTable[len-1]): \r\n\r\n\t\t\t# A[i] wants to extend \r\n\t\t\t# largest subsequence \r\n\t\t\ttailTable[len] = A[i] \r\n\t\t\tlen+= 1\r\n\r\n\t\telse: \r\n\t\t\t# A[i] wants to be current \r\n\t\t\t# end candidate of an existing \r\n\t\t\t# subsequence. It will replace \r\n\t\t\t# ceil value in tailTable \r\n\t\t\ttailTable[CeilIndex(tailTable, -1, len-1, A[i])] = A[i] \r\n\t\t\r\n\r\n\treturn len\r\n\r\n\r\nT=int(input())\r\nwhile T:\r\n    N=int(input())\r\n    ls=[]\r\n    for i in range(N):\r\n        a,b=map(int,input().split())\r\n        ls.append([a,b])\r\n    ls.sort()\r\n    temp=[ls[i][1] for i in range(N)]\r\n    print(LongestIncreasingSubsequenceLength(temp,N))\r\n    T-=1'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13421