#include<bits/stdc++.h>

  //
              #define ll long long
              #define F first
              #define S second
              #define vi vector<int>
              #define vc vector<char>
              #define vll vector<ll>
              #define vb vector<bool>
              #define vvc vector<vector<char> >
              #define vvi vector<vector<int> >
              #define endl '\n'
              #define f(i,j,n,k) for(int i=j;i<n;i+=k)
              #define all(c) c.begin(),c.end()
              #define allr(c) c.rbegin(),c.rend()
              #define pb push_back
              #define mp make_pair
              #define hell 998244353
using namespace std;


  ll gcdfun(ll x,ll y){
      if(y==0) return x;
      else return gcdfun(y,x%y);
  }
template <typename X> void swap(X *x, X *y){
      X temp; temp = *x;
      *x = *y;
      *y = temp;
}

  ll power(ll a,ll n)
  {
      if(n==0) return 1;
      ll p = power(a,n/2);
      p*=p;
      //p=p%hell;
      if(n&1) p*=a;
      return p;
  }

  ll mul(ll a,ll b)
  {
      return (a*b)%hell;
  }
ll MAX = 100000000000000000;
ll inf = 1e17;

bool check1(char c){
  if(c == '0' || c=='1' || c=='8' || c=='2' || c=='5') return true;
  else return false;
}

void solve(){
     ll n,k , mex=-1; cin>>n>>k;
     vll v(n);
     unordered_map<ll,bool> check;
     f(i,0,n,1) cin>>v[i], check[v[i]]=true;
     sort(all(v));
     if(k==0){cout<<n; return;}
     if(v[0]!=0) mex = 0;
     else if(v[0]==0){
      f(i,0,n-1,1){
        if(v[i+1] != v[i]+1) {mex = v[i]+1; break; }
      }
     }
     if(mex==-1) {
      cout<<n+k; return;
     }


     if( check[(mex + v[n-1] + 1)/2] ) cout<<n; else cout<<n+1; 

}

int main(){
  // 
 #ifndef ONLINE_JUDGE
                  // or getting input from input.txt
                  freopen("input.txt", "r", stdin);
                  // for writing output to output.txt
                  freopen("output1.txt", "w", stdout);
  #endif

ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

            int t=1;
            cin>>t;

            while(t--){
              solve();  cout<<endl;
            }
            return 0;
  }