// #pragma GCC optimize(3)
// #pragma GCC optimize(2)
#include <map>
#include <set>
// #include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define Time (double)clock() / CLOCKS_PER_SEC

#define sd(a) scanf("%d", &a)
#define sdd(a, b) scanf("%d%d", &a, &b)
#define slld(a) scanf("%lld", &a)
#define slldd(a, b) scanf("%lld%lld", &a, &b)
#define INF 0x3f3f3f3f

const int N = 1e5 + 20;
const int M = 1e2 + 20;
const int mod = 998244353;
const double eps = 1e-8;

int n, k;
int s[N];
map<int, int> mp;

void solve()
{
	cin >> n >> k;
	
	int a = 0, b = 0;
	mp.clear();
	for(int i = 0; i < n; i ++){
		cin >> s[i];
		mp[s[i]] ++;
		b = max(b, s[i]);
	}

	int num = mp.size();

	for(int i = 0; i <= n; i ++){
		if(!mp[i]){
			a = i;
			break;
		}
	}

	if((a + b + 1) / 2 == b + 1) cout << num + k << "\n";
	else{
		if(mp[(a + b + 1) / 2]) cout << num << "\n";
		else cout << num + min(1, k) << "\n"; 
	}

}

int main()
{
#ifdef ONLINE_JUDGE
#else
	freopen("/home/jungu/code/in.txt", "r", stdin);
	// freopen("/home/jungu/桌面/T2/13.in", "r", stdin);
	// freopen("/home/jungu/桌面/T2/13.out","w",stdout);
#endif
	// ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	int T = 1;
	// sd(T);
	cin >> T;
	// cin >> k;
	// get(N - 20);
	// init();
	// int cas = 1;
	while (T--)
	{
		// printf("Case #%d:", cas++);
		solve();
	}

	return 0;
}