#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 50;
#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define debug(a) cout << #a << ' ' << a << '\n';
#define debug2(a , b) cout << #a << ' ' << a << " || " << #b << ' ' << b << '\n';
#define ye cout << "YES\n"
#define no cout << "NO\n"
#define cn cout << "\n" 
const int mod = 1e9 + 7;
using namespace std;

int a[maxn];
signed main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int t;
	cin >> t;
	while(t --){
		int n , k;
		cin >> n >> k;
		for(int i = 1 ; i <= n ; i ++) cin >> a[i];
		if(k == 0){
			cout << n << '\n';
			continue;
		}
		sort(a + 1 , a + 1 + n);
		int ok = 1;
		for(int i = 1 ; i <= n ; i ++){
			if(a[i] != i - 1) {
				ok = 0;
				break;
			}
		}
		if(ok){
			cout << n + k << '\n';
			continue;
		}
		int ans = n;
		int one = -1;
		if(a[1] != 0)one = 0;
		else{
			for(int i = 1 ; i <= n ; i ++){
				if(a[i] - a[i - 1] > 1){
					one = a[i - 1] + 1;
					break;
				}
			}
		}
		if(one == -1) one = a[n] + 1;
		//debug(one)
		one = ((one + a[n]) % 2 == 0 ? (one + a[n]) / 2 : (one + a[n] + 1) / 2);
		ans ++;
		//debug(one)
		for(int i = 1 ; i <= n ; i ++){
			if(a[i] > one) break;
			if(one == a[i]){
				ans --;
				break;	
			}
		}
		cout << ans << '\n';
	} 
	return 0; 
}
/*

0 1 2
0 1 2 3

*/