#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int qw = 0; qw < q; qw++) {
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    while (a[a[1]] < a[1]) {
      a[1]--;
    }
    cout << a[1] << endl;
  }
}
