Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. 
Each customer that visits the restaurant has a strongly preferred compartment p (1 ≤ p ≤ K), and if that compartment is already occupied, then the customer simply leaves. Now obviously, the chef wants to maximize the total number of customers that dine at his restaurant and so he allows (or disallows) certain customers so as to achieve this task. You are to help him with this. 
Given a list of N customers with their arrival time, departure time and the preferred compartment, you need to calculate the maximum number of customers that can dine at the restaurant. 

-----Input-----
The first line contains an integer T denoting the number of test cases. Each of the next T lines contains two integers N and  K , the number of customers that plan to visit the chef's restaurant and the number of compartments the restaurant is divided into respectively. Each of the next N lines contains three integers si, fi and pi , the arrival time, departure time and the strongly preferred compartment of the ith customer respectively.  

Note that the ith customer wants to occupy the pith compartment from [si, fi)  i.e the ith customer leaves just before   fi  so that another customer can occupy that compartment from   fi  onwards.

-----Output-----
For every test case, print in a single line the maximum number of customers that dine at the restaurant.

-----Constraints-----
-  1 ≤  T ≤   30 
-  0  ≤ N  ≤  105 
-  1  ≤  K  ≤  109 
-  0  ≤  si < fi ≤   109 
-  1  ≤  pi  ≤  K  

-----Example-----
Input:
2
3 3
1 3 1
4 6 2
7 10 3
4 2
10 100 1
100 200 2
150 500 2
200 300 2

Output:
3
3

-----Explanation-----
Example case 1.

All three customers want different compartments and hence all 3 can be accommodated.

Example case 2.

If we serve the 1st, 2nd and 4th customers, then we can get a maximum of 3.

```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 = '# cook your dish here\nfrom sys import stdin\ndef cal(a):\n \n a.sort(key=lambda x:x[1])\n len1=len(a)\n c=1\n curr=a[0][1]\n for p in range(0,len1-1):\n  if curr<=a[p+1][0]:\n   c+=1\n   curr=a[p+1][1]\n return c\n \n \n \nt=int(input())\nfor i in range(t):\n n,k=list(map(int,stdin.readline().split()))\n list1=[]\n a=[]\n count=0\n for j in range(n):\n  s,f,p=list(map(int,stdin.readline().split()))\n  list1.append((s,f,p))\n list1.sort(key=lambda x:x[2])\n for j in range(0,n-1):\n  if list1[j][2]==list1[j+1][2] and j!=n-2:\n   a.append((list1[j][0],list1[j][1]))\n  elif list1[j][2]==list1[j+1][2] and j==n-2:\n   a.append((list1[j][0],list1[j][1]))\n   a.append((list1[j+1][0],list1[j+1][1]))\n   \n   count+=cal(a)\n   a=[]\n  elif list1[j][2]!=list1[j+1][2] and j==n-2:\n   a.append((list1[j][0],list1[j][1]))\n   count+=cal(a)\n   a=[]\n   a.append((list1[j+1][0],list1[j+1][1]))\n   count+=cal(a)\n   a=[]\n  else:\n   a.append((list1[j][0],list1[j][1]))\n   count+=cal(a)\n   a=[]\n if n==1:\n  print(count+1)\n else:\n  print(count)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14425