/*
-----------------------------------------------------------------------------
                ---------------------------------------------------------
    RR  ---------------------------------------------------------
                ---------------------------------------------------------
-----------------------------------------------------------------------------
*/
#include <bits/stdc++.h> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);
#define for_t  long long int T;cin>>T;while(T--)
#define endl "\n"
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define ff first
#define ss second
#define mod 1000000007
#define mod9 1000000009
#define MAX 1e15
#define yes "YES"
#define no "NO"
using namespace  std;

ll findFirstMissing(vector<ll>array,   ll start, int end) 
{ 
    if (start > end) 
        return end + 1; 
  
    if (start != array[start]) 
        return start; 
  
    ll mid = (start + end) / 2; 
  
    // Left half has all elements  
    // from 0 to mid 
    if (array[mid] == mid) 
        return findFirstMissing(array, mid+1, end); 
  
    return findFirstMissing(array, start, mid); 
} 


int main()
{
    FIO;
    
    for_t
    {
        ll n,k;
        cin>>n>>k;

       
        vector<ll>v;
        
  

        for(ll i=0;i<n;i++)
        {
            ll p;
            cin>>p;
            v.pb(p);
        }

        ll ans=n;

        

        sort(v.begin(),v.end());

        ll cnt=0;

        for(int i=0;i<v.size();i++)
        {
            if(cnt==v[i])
                cnt++;
            else
                break;
        }

        if(cnt==n)
            cout<<n+k<<endl;
        else
        {

            ll x=v[n-1];
            ll y=cnt;

            ll z=ceil((x+y+0.0)/2);

            if(binary_search(v.begin(), v.end(),z) ==false && k!=0)
                cout<<ans+1<<endl;
            else
                cout<<ans<<endl;

        }

        





    }
    



}

