#include<bits/stdc++.h> 
using namespace std;
#define int long long int 
#define endl '\n'
#define mod 1000000007
const int N= 1e7+10;
vector<int>a;
vector<vector<int>>v;

signed main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    
    int t;cin>>t;
    while(t--)
    {
        int n,k;cin>>n>>k;
        a.assign(n,0);
        map<int,int>mp;
        for(int i=0;i<n;i++) cin>>a[i];
        for(int i=0;i<n;i++)
            mp[a[i]]++;
        set<int>sp;
        for(int i=0;i<n;i++)
            sp.insert(a[i]);
        int sz=sp.size();
        int mex;
        for(int i=0; ; i++)
        {
            if(mp.find(i)!=mp.end())
                continue;
            mex=i;
            break;
        }
        int mx= *max_element(a.begin(),a.end());
        int rd = (mx+mex+1)/2;
        int sum=0;
        for(int i=0;i<n;i++)
            sum+=a[i];
        if(k==0)
        {
            cout<<sz<<endl;
            continue;
        }
        if(n*(n-1)/2 == sum)
        {
            cout<<n+k<<endl;
            continue;
        }
        if(mp.find(rd)!=mp.end())
            cout<<sz<<endl;
        else
            cout<<sz+1<<endl;
    }
    return 0;
}