#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define f(i, l, r) for(int i=l;i<=r;i++)
#define debug(x) cout<<#x<<'='<<(x)<<endl
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

using PLL = pair<ll, ll>;
using VL = vector<ll>;
using VLL = vector<pair<ll, ll>>;

// -------------------------------------------------------------------------------
ll mod = 1e9 + 7;

void setIO(string name = "") {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (sz(name)) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
// -------------------------------------------------------------------------------
// ------------------------Template End ------------------------------------------
// -------------------------------------------------------------------------------



void tsolve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int max_ = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        max_ = max(max_, a[i]);
    }
    if(k == 0){
        cout << n << "\n";
        return;
    }

    sort(all(a));
    int mex = -1;
    if(a[0] == 0) {
        for (int i = 1; i < n; i++) {
            if (a[i] - a[i - 1] > 1) {
                mex = a[i - 1] + 1;
                break;
            }
        }
    }
    else {
        mex = 0;
    }
    if (mex == -1) {
        // this is a range
        cout << n + k << "\n";
        return;
    }
    int new_num = ceil((max_ + mex) / 2.0f);
    bool there = false;
    for(auto num: a) {
        if(num == new_num) {
            there = true;
            break;
        }
    }
    if(there)
        cout << n << "\n";
    else
        cout << n + 1 << "\n";
}

int main() {
    setIO();
    int gsc;
    cin >> gsc;
    while (gsc--) {
        tsolve();
    }
    return 0;
}