#include <bits/stdc++.h>
using namespace std;
int sidelen(int *a, int n) {
  int i, j, count = 0, temp;
  sort(a, a + n);
  temp = a[n - 1];
  if (n == 1) {
    return 1;
  }
  for (i = n - 1; i >= 0; i--) {
    count++;
    if (a[i] != a[i + 1]) {
      temp = a[i];
    }
    if (count == temp) {
      return count;
    }
    if (count > temp) {
      return count - 1;
    }
  }
}
int main() {
  int t;
  cin >> t;
  for (int l = 0; l < t; l++) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    cout << sidelen(a, n) << endl;
  }
  return 0;
}
