#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

#define ll long long int

int main() {
	fast_cin();
     int t,n,k,d;
     cin>>t;
     for(int h=0;h<t;h++){
     	cin>>n>>k;
     	int a[n];
     	for(int i=0;i<n;i++){
     		cin>>a[i];
     	}
     	sort(a,a+n);
     	if(k==0)
     	{
     		cout<<n<<endl;
     	}
     	else if(a[n-1]+1==n){
     		cout<<n+k<<endl;
     	}
     	else{
     		for(int i=0;i<n;i++){
     			if(a[i]!=i){
     				d=round((float)(i+a[n-1])/2);
     				if(binary_search(a,a+n,d)){
     					cout<<n<<endl;
     				}
     				else
     					cout<<n+1<<endl;
     				break;
     			}
     		}
     	}



     }  


    return 0;
}
