#include<cstdio>
#include<algorithm>
#include<ctype.h>
#define int long long

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
} 
 
int T,n,k,a[100005],ans;

bool check(int x)
{
	for(int i=1;i<=n;i++)	
		if(a[i]==x)return false;
	return true;
}

signed main()
{
	T=read();
	while(T--)
	{
		n=read(),k=read();
		for(int i=1;i<=n;i++)
			a[i]=read();
		sort(a+1,a+n+1);
		int maxx=0,mex=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==mex)mex++;
			maxx=max(maxx,a[i]);	
		} 
		if(maxx>mex&&k!=0)
		{
			int ret=(maxx+mex)/2;
			if((maxx+mex)&1)
				ret++;
			if(check(ret))
				printf("%lld\n",n+1);
			else
				printf("%lld\n",n);
		}
		else
			printf("%lld\n",n+k);
	}
}