#include<bits/stdc++.h>
using namespace std;

int n, t, k, a, maxn, minn;
map<int, bool> Map;

template<typename T>
inline void read(T&x){
	x=0; char q; bool f=1;
	while(!isdigit(q = getchar()))	if(q == '-')	f = 0;
	while(isdigit(q)){
		x = (x<<1)+(x<<3)+(q^48);
		q = getchar();
	}
	x = f?x:-x;
}

template<typename T>
inline void write(T x){
	if(x<0){
		putchar('-');
		x = -x;
	}
	if(x>9)	write(x/10);
	putchar(x%10+'0');
}

int main(){
	read(t);
	while(t--){
		maxn = -0x3f3f3f3f;
		minn = 0;
		Map.clear();
		read(n), read(k);
		for(register int i = 1; i <= n; ++i){
			read(a);
			Map[a] = true;
			if(a > maxn)	maxn = a;
		}
		if(k == 0){
			write(n);
			putchar((char)10);
			continue;
		}
		for(register int i = 0; i <= maxn+1; ++i){
			if(Map[i])	continue;
			minn = i;
			break;
		}
		if(maxn > 0){
			if(minn > maxn){
				write(n+k);
				putchar((char)10);
				continue;
			}
			if(Map[(minn+maxn+1)/2]){
				write(n);
				putchar((char)10);
				continue;
			}
			write(n+1);
			putchar((char)10);
			continue;
		}
		write(n+k);
		putchar((char)10);
		continue;
	}
	return 0;
}
