#include<bits/stdc++.h>
using namespace std;
#define ll long long
set<ll>s;
int main()
{
    ll t,n,k,a[100010];
    cin>>t;
    while(t--)
    {
        s.clear();
        ll mx=0;
        cin>>n>>k;
        for(int i=0; i<n; i++)
            cin>>a[i],s.insert(a[i]),mx=max(mx,a[i]);
        //cout<<"h"<<endl;

        ll mex;
        if(k==0)
            cout<<n<<endl;
        else
        {
            for(ll i=0; i<=n+1; i++)
                if(s.count(i)==0)
                {
                    mex=i;
                    //cout<<"hhh"<<endl;
                    break;
                }
            if(mex<=mx)
            {
                if(s.count((mex+mx+1)/2)==0)
                    cout<<n+1<<endl;
                else
                    cout<<n<<endl;
            }
            else
            {
                cout<<n+k<<endl;
            }
        }

    }
}
