#include <iostream> #include <string> #include <string.h> #include <vector> #include <stdio.h> #include <algorithm> #include <map> #include <math.h> typedef long long LL ; std::vector<int> stone ; int main(){ int t , limit , x , n , m , L , R , used , unUsed ; scanf("%d" , &t) ; while(t--){ limit = 0 ; stone.clear() ; scanf("%d%d" , &n , &m) ; for(int i = 0 ; i < n ; i++){ scanf("%d" , &x) ; if(x) stone.push_back(x) ; else limit++ ; } std::sort(stone.begin() , stone.end()) ; stone.erase( std::unique(stone.begin() , stone.end()) , stone.end() ) ; int res = std::min(m , limit) ; for(L = 0 , R = 0 ; L < stone.size() ; L++){ while(R < stone.size() && stone[R] - stone[L] + 1 <= R - L + 1 + limit) R++ ; R-- ; used = (stone[R] - stone[L] + 1 ) - ( R - L + 1 ) ; unUsed = limit - used ; res = std::max(res , stone[R] - stone[L] + 1 + std::min(unUsed , m - (stone[R] - stone[L] + 1))) ; } std::cout<< res << std::endl ; } return 0 ; }