#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;

#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define forab(i,a,b) for(ll i=a;i<=b;++i)
#define forn(n) for(ll i=0;i<n;++i)
#define fcout(n,i) cout<<fixed<<setprecision(i)<<n<<endl

const ll mod = 1e9 + 7;
ll inf = 1e16;
const double ep = 1e-8;

void solve()
{
  ll n,k;
  cin>>n>>k;
  set<ll> stc;
  forn(n){
  	ll x;
  	cin>>x;
  	stc.insert(x);
  }
  ll maxi = *(--stc.end());
  ll mexi= n;
  ll val = 0;
  for(auto vv : stc)
  {
  	if(val != vv){
  		mexi = val;
  		break;
	  }
	  ++val;
  }
  //cout<<maxi<<" and mexi is "<<mexi<<endl;
  
  if(k == 0){
  	cout<<n<<endl;
  	return;
  }
  
  if(mexi < maxi){
  	ll fillvalue = ceil((mexi + maxi)/(2*1.0));
  	if(stc.count(fillvalue)){
  		cout<<n<<endl;
	  }else{
	  	cout<<n+1<<endl;
	  }
  }else if(mexi > maxi){
  	  cout<<(n+k)<<endl;
  }
}

int main()
{
	fastio;
	ll test=1;
	cin>>test;
	while(test--){
		solve();
	}
	return 0;
}


