#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    int skill, count = 1;
    unordered_map<int, int> skills;
    for (int i = 0; i < n; i++) {
      cin >> skill;
      if (skills.count(skill) == 0)
        skills[skill] = 1;
      else {
        skills[skill] += 1;
        count = max(count, skills[skill]);
      }
    }
    if (skills.size() == count)
      cout << count - 1 << endl;
    else if (skills.size() < count)
      cout << skills.size() << endl;
    else
      cout << count << endl;
  }
  return 0;
}
