Chef Tobby is trying to run a code given to him by Bhuvan for an experiment they want to include in the manuscript to be submitted to a conference. The deadline to submit the manuscript is within a couple of hours and Chef Tobby needs to finish the experiments before then.
The code given by Bhuvan is the following which runs given an array of N integers and another integer K :
void recurse ( array a, int n )
{
	// n = size of array
	define array b currently empty
	consider all 2^n subsets of a[]
	{
		x = bitwise OR of elements in the subsets
		add x into "b" if it is not present yet
	}
	if (sizeof( b ) == 1 << k)
	{
		printf(“Won”);
		return;
	}
	recurse ( b, sizeof( b ) );
}
Chef Tobby tried to run an experiment with only one integer in the array with value 2 and K = 3. To his horror, he found out that the algorithm is resulting in an infinite loop. He is livid with the possibility that the algorithm can lead to infinite loops for certain cases. On closer inspection he determines that it might be possible to insert additional elements in the initial array to subvert the problem. Since time is very less, Chef Tobby would like to insert the minimum number of elements.
Chef Tobby has to finish writing the paper, so he asks his graduate student Leamas to fix it. Leamas has no idea how to fix the problem so he asks you for help.
-----Input section-----
The first line contains T, the number of test cases.
Each test case consists of 2 lines. The first line contains 2 integers N and K, denoting the number of elements in the array and parameter mentioned in problem statement.
Next line contains N space separated integers, denoting the elements of the array.
-----Output section-----
Output the minimum number of elements that need to be inserted so that inifinite loop can be avoided.
-----Input constraints-----
1 ≤ T ≤ 10
1 ≤ Sum of N over all test cases ≤ 105
1 ≤ K ≤ 20
0 ≤ A[i] ≤ 2K-1, where A[i] denotes the ith element of the array.
-----Sample Input - 1-----
1
2 2
3 1
-----Sample Output - 1-----
1
-----Explanation - 1-----
You can win the game by inserting the element 2 into the array.
-----Sample Input - 2-----
1
7 3
3 7 5 4 6 2 1
-----Sample Output - 2-----
0
-----Explanation - 2-----
The initial array will result will terminate in the first step of algorithm only. Thus there is no need to insert any new element.
from bisect import *
for x in range(eval(input())):
 n,k = list(map(int,input().split()))
 arr = list(map(int,input().split()))
 arr.sort()
 t = 1
 ans = 0
 y = 0
 while y < n:
  if arr[y]<t:
   y += 1
  elif arr[y]==t:
   t = t*2
   y += 1
  else:
   ans += 1
   t = t*2
 #print t,ans
 while t < 2**(k):
  #print 1
  ans += 1
  t = t*2
 print(ans)
from bisect import *
for x in range(eval(input())):
 n,k = list(map(int,input().split()))
 arr = list(map(int,input().split()))
 arr.sort()
 t = 1
 ans = 0
 y = 0
 while y < n:
  if arr[y]<t:
   y += 1
  elif arr[y]==t:
   t = t*2
   y += 1
  else:
   ans += 1
   t = t*2
 #print t,ans
 while t < 2**(k):
  #print 1
  ans += 1
  t = t*2
 print(ans)