#include <bits/stdc++.h>
using namespace std;
int myfunc(int a, int b) { return a > b; }
int main() {
  int t;
  cin >> t;
  while (t--) {
    vector<int> vec;
    int a, n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a;
      vec.push_back(a);
    }
    sort(vec.begin(), vec.end(), myfunc);
    int p = vec[0];
    for (int i = 0; i < max(n, p); i++) {
      if (vec[0] <= n) {
        if (vec[vec[0] - 1] >= vec[0]) {
          break;
        } else {
          vec[0] = vec[0] - 1;
        }
      } else {
        vec[0] = vec[0] - 1;
      }
    }
    cout << vec[0] << endl;
  }
  return 0;
}
