#include <bits/stdc++.h>

using namespace std;

void mainHelper() {
    int n, k;
    cin >> n >> k;
    set<int> stz;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        stz.insert(x);
    }

    int z = 0;
    while (stz.find(z) != stz.end()) {
        z++;
    }
    int res;
    if (!k) {
        res = n;
    } else if (z > (*--stz.end())) {
        res = n+k;
    } else if (stz.find((z+(*--stz.end())+1)/2) == stz.end()) {
        res = n+1;
    } else {
        res = n;
    }

    cout << res << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	cin >> t;
	while (t--) {
	    mainHelper();
    }
	return 0;
}

