#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<tuple<string, int, int>> all;
for (int i = 0; i < n; i++) {
string name; cin >> name;
int k; cin >> k;
set<int> S;
for (int j = 0; j < k; j++) {
int x; cin >> x;
S.insert(x);
}
all.push_back({ name, (int)S.size(), k });
S.clear();
}
sort(all.begin(), all.end(), [&](tuple<string, int, int> x, tuple<string, int, int> y) {
if (get<1>(x) != get<1>(y)) {
return get<1>(x) > get<1>(y);
}
return get<2>(x) < get<2>(y);
});
if (n >= 3) {
cout << get<0>(all[0]);
for(int i = 1; i < 3; i++) cout << " " << get<0>(all[i]);
} else if (n == 2) {
cout <<get<0>(all[0]);
for(int i = 1; i < 2; i++) cout << " " << get<0>(all[i]);
cout << " " << "-" << endl;
} else if (n == 1) {
cout << get<0>(all[0]);
cout << " - -";
} else cout << "- - -";
return 0;
}
//9
//6
//10
//9
//9
//