#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
       int n,k;
       cin>>n>>k;
       ll a[n];
       int ans=0;
       unordered_set<ll>s;
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
           s.insert(a[i]);
       }
       sort(a,a+n);
       ll p=n;
       ll q=a[n-1];
       for(int i=0;i<n;i++)
       {
           if(a[i]!=i)
           {
               p=i;
               break;
           }
       }
       if(k==0)
       {
           ans=n;
       }
       else if(p>q)
       {
           ans=n+k;
       }
       else
       {
           ans=n;
           int m=(p+q+1)/2;
           if(s.find(m)==s.end())
           {
               ans=n+1;
           }
       }
       cout<<ans<<endl;
    }
}