#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

#define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr))
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define iter(it, s) for (auto it = s.begin(); it != s.end(); it++)
#define fillc(a,b) memset(a,b,sizeof(a))
#define MOD 1000000007

void solve()
{
    set<ll> s,nd;
    ll n,k,i,num;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>num;
        s.insert(num);
    }
    if(k==0)
    {
        cout<<n<<endl;
        return;
    }
    if(*s.rbegin()==(n-1))
    {
        cout<<n+k<<endl;
        return;
    }
    i=0;
    for(auto it=s.begin();it!=s.end();it++,i++)
        if(*it!=i)
            break;
    if(s.count((i+*s.rbegin())%2?(i+*s.rbegin())/2+1:(i+*s.rbegin())/2))
        cout<<n<<endl;
    else
        cout<<n+1<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin>>t;
    while(t--)
        solve();
}
