// Problem: B. Max and Mex
// Contest: Codeforces - Codeforces Round #706 (Div. 2)
// URL: https://codeforces.com/contest/1496/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vc vector<char>
#define vvi vector<vector<ll>>
#define MAX 1e10
#define MIN -1e10
#define s(a) sort(a.begin(),a.end())
#define pq priority_queue<ll>
#define npq priority_queue<ll, vector<ll>, greater<ll>>
//Global Variable Definition.....
bool Binary_Search(vi &arr,ll n,ll s) {
	ll low=0,high=n-1,mid;
	while(low<=high) {
		mid=low+(high-low)/2;
		if(arr[mid]==s)
		return true;
		else if(arr[mid]>s)
		high=mid-1;
		else
		low=mid+1;
	}
	return false;
}
void abcd() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,n,k;
	cin>>n>>k;
	vi arr;
	for(ll i=0;i<n;i++) {
		cin>>a;
		arr.push_back(a);
	}
	ll c=0;ll i;
	if(k==0) {
		cout<<arr.size();
		return;
	}
	s(arr);
		for(i=0;i<n;i++) {
			if(arr[i]!=i)
			break;
		}
		if(i==arr.size()) {
			cout<<(n+k);
			return;
		}
		if(!(Binary_Search(arr,arr.size(),(arr[arr.size()-1]+i)/2+(arr[arr.size()-1]+i)%2))) {
			cout<<arr.size()+1;
			return;
		}
		else
	cout<<arr.size();
}
int main() {
	ll t;
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>t;
	while(t--) {
		abcd();
		cout<<endl;
	}
}