#include <iostream>
#include <bits/stdc++.h>
#define int long long
using namespace std;
void file_i_o()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
}
int mex(vector<int> &nums)
{
    int smallest = 0;
    for (int i = 0; i < nums.size(); i++)
    {
        if (nums[i] < 0)
            continue;
        if (nums[i] > smallest)
            break;
        if (nums[i] == smallest)
            smallest++;
    }
    return smallest;
}

int32_t main()
{
    file_i_o();
    int t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        vector<int> arr(n);
        unordered_set<int> distinct;
        for (int i = 0; i < n; i++)
        {
            cin >> arr[i];
            distinct.insert(arr[i]);
        }
        sort(arr.begin(), arr.end());
        int first_mex = mex(arr);
        if(first_mex < arr[n-1] && k > 0){
            distinct.insert(ceil(((double)(first_mex + arr[n-1]))/ 2) );
            cout<<distinct.size()<<endl;
        }else{
            cout<<distinct.size() + k<<endl;
        }
    }
}