Read problems statements in Mandarin Chinese and Russian as well. 
There is a party going on in a club situated in some city. N gangsters will attend that party. The i-th gangster comes to the party at the beginning of S_{i} time and will leave the party at the end of E_{i}. At any time unit, the set of gangsters who are present in the party enjoy drinking together and become friends. After the party, the law enforcement agency in the city is suspecting that there has been some conspiracy for sabotage in the city. So they feel that it is necessary to interrogate several gangsters. But they don't have time to interrogate all of them. They are suspecting that there are X gangsters involved in this conspiracy. It is natural that those X gangsters will be friends with each other.

Now the enforcement agency have got the idea. They want to interrogate the gangsters in such a way that for each subset of X friend gangsters (where each pair of gangsters in that subset are friends), there will be at least one interrogated gangster from that subset. But to save their time, they want to interrogate minimum number of gangsters. Given the information of the gangsters and number X, help them to find the minimum number of gangsters to be interrogated.

Note: Two gangsters are friends if they have common time in the club. For example, the gangster entering at time 1 and leaving at time 3 can be a friend with another gangster entering at time 3 and leaving some time afterwards. But a gangster leaving at time 3 cannot be a friend with another gangster entering at time 4.

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case starts with a line containing N and X. Each of the next N lines contains, the arrival S_{i} and the departure E_{i} of a gangster. 

------ Output ------ 

For each test case, output a single line containing the minimum number of gangsters that the city law enforcement agency should interrogate. 

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ X ≤ N ≤ 200$
$1 ≤ S_{i} ≤ E_{i} ≤ 10^{9}$

------ Example ------ 

Input:
3
3 2
1 3
3 5
4 6
4 3
1 8
2 9
3 10
4 11
4 3
1 5
4 9
8 13
12 17

Output:
1
2
0

------ Explanation ------ 

Example case 1. Gangsters 1 and 2 are friends each other. Also Gangsters 2 and 3 are friends with each other. So it is enough to interrogate gangster 2 only.
Example case 2.All of the four gangsters are friends with each other. The police suspects that the size of the group is 3. So it is enough to interrogate any two of the gangsters.
Example case 3.There is not any group of 3 gangsters, where each of them are friends with each other. So the police don't need to interrogate anybody.

Difficulty: VERY_HARD
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
for i in range(int(input())):
	(N, X) = map(int, input().split())
	times = []
	friends = [1] * N
	for j in range(N):
		times.append(list(map(int, input().split())))
	times.sort(key=lambda x: x[1])
	ans = 0
	for i in range(1, N):
		for j in range(i):
			if times[i][0] <= times[j][1]:
				friends[j] += 1
		flag = False
		for l in range(i):
			if X == friends[l]:
				flag = True
				ans += 1
				break
		if flag:
			for k in range(i + 1):
				friends[k] -= 1
	print(ans)


T = int(input())
for i in range(T):
	(N, X) = list(map(int, input().strip().split()))
	cases = []
	frds = [1] * N
	for j in range(N):
		cases.append(tuple(map(int, input().strip().split())))
	cases.sort(key=lambda x: x[1])
	ans = 0
	for i in range(1, len(cases)):
		for j in range(i):
			if cases[i][0] <= cases[j][1]:
				frds[j] += 1
		check = 0
		for l in range(i):
			if X == frds[l]:
				check = 1
				ans += 1
				break
		if check == 1:
			for k in range(i + 1):
				frds[k] -= 1
		else:
			continue
	print(ans)