#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define spr(a) fixed<<setprecision(a)
#define fir first
#define sec second
#define make make_pair
#define PP push_back
using namespace std;
 
typedef long long LL;
typedef double DD;
typedef bool BB;
typedef pair<string,LL> PAIR;
 
const LL INF=1e18;
const LL mod=1e9+7;
const LL N=1e5+10;
 
LL n,m,cnt=0,ans=0,sum=0,t,k,q,p;
LL arr[N];
vector<LL>vec;

LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL max(LL x,LL y){return x>y?x:y;}
LL getMex(void)
{
    for(LL i=0;i<n;i++)
    {
        if(vec[i]!=i) return i;
    }
    return vec[n-1]+1;
}
int main(void)
{
    for(scanf("%lld",&t);t;t--)
    {
        vec.clear();
        LL Mex=0;
        scanf("%lld%lld",&n,&k);
        for(LL i=0;i<n;i++)
        {
            scanf("%lld",&m);
            vec.PP(m);
        }
        sort(vec.begin(),vec.end());
        Mex=getMex();
        q=LL(ceil(DD(Mex+vec[n-1])/2));
        if(Mex>vec[n-1]) ans=n+k;
        else
        {
            p=lower_bound(vec.begin(),vec.end(),q)-vec.begin();
            if(vec[p]==q) ans=n;
            else ans=n+1;
        }
        if(k==0) ans=vec.size();
        printf("%lld\n",ans);
    }
    // system("pause");
    return 0;
}
