#include <bits/stdc++.h>
#define ll long long
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define nmax 200005
#define ii pair<ll,ll>
#define fi first
#define se second
#define oo 1e18
using namespace std;
const int mod = 1e9 + 7;
ll t,n,k,a[nmax];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("new.inp","r",stdin);
        freopen("new.out","w",stdout);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>t;
    while(t--)
    {
        cin>>n>>k;
        fo(i,1,n)
            cin>>a[i];
        sort(a+1,a+1+n);
        ll res = n;
        fo(i,1,n)
        if(a[i] != i-1)
        {
            res = i-1;
            break;
        }
        if(res > a[n])
            cout<<n+k<<'\n';
        else
        {
            ll tmp = (res + a[n]) / 2;
            ll p = 1;
            if((res+a[n]) % 2 == 1)
                tmp++;
            fo(i,1,n)
            if(a[i] == tmp)
                p = 0;
            if(k == 0)
                cout<<n<<'\n';
            else cout<<n+p<<'\n';
        }
    }
}
