#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define cerr if(1) cerr
#define ll long long
#define fp cout<<fixed<<setprecision(9);
#define loop(var,s,n) for(ll var=s ;var<n;var++)
#define rloop(var,s,n) for(ll var=s ;var>=n;var--)
#define pb push_back
#define endl '\n'
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define ipair pair<ll,pair<ll,ll>>
using namespace std;
ll findmex(set<ll>&v, ll mi)
{
	while (v.find(mi) != v.end())
	{
		mi++;
	}
	return mi;
}
int main() {

#ifdef KEVIN
	freopen("ingoing3.txt", "r", stdin);
	freopen("outgoing3.txt", "w", stdout);
	freopen("err3.txt", "w", stderr);
#endif
	FAST
	int t;
	cin >> t;
	while (t--)
	{
		ll n, k;
		cin >> n >> k;
		set<ll>s;
		loop(i, 0, n)
		{
			ll te;
			cin >> te;
			s.insert(te);
		}
		if (k == 0)
		{
			cout << s.size() << endl;
			continue;
		}
		ll mi = 0;
		ll ans = s.size();
		while (k > 0)
		{
			mi = findmex(s, mi);
			//cout << mi << " ";
			if (mi >= *s.rbegin())
			{
				ans = s.size() + k;
				break;
			}
			ll temp = (mi + *s.rbegin() + 1) / 2;
			if (s.find(temp) != s.end())break;
			s.insert(temp);
			ans = s.size();
			k--;


		}
		cout << ans << endl;

	}
}