#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
const int N=3e5+9;

void solve()
{
    int n, k, mx = -1;
    cin >> n >> k;
    set<int>s;
    int a[n+1];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s.insert(a[i]);
        mx = max(mx,a[i]);
    }
    sort(a,a+n);
    int i = 0;
    while(i < n && i==a[i]) i++;
    int mex = i;
    if(mex > mx) {cout << n + k << endl; return;}
    int ok = false;
    //cout << "mx: " << mx << " mex: " << mex << endl;
    int p = (mx+mex) / 2 + ((mx+mex)%2);
    for(int j = 0; j < n; j++) if(a[j] == p) {ok = true; break;}
    if(!ok && k ) cout << n + 1 << endl;
    else cout << n << endl;
}

int main()
{
    IOS;
    int t;
    cin >> t;
    while(t--) solve();

    return 0;
}
// 0 1 2 3 4 5
// mx = 5, mex = 5