#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
vector<set<string>> sets(n);
for(int i= 0;i<n;i++) {
int m;
cin>>m;
for(int j = 0;j<m;j++) {
string str;
cin>>str;
sets[i].insert(str);
}
}
//对于每个集合Si,寻找与其交集最大且序号最小的Sj
for (int i = 0;i<n;i++){
int max_common = INT_MIN;
int index = INT_MAX;
for (int j = 0;j<n;j++){
if (j==i) continue;
int common = 0;
for (const auto& item : sets[j]){
if (sets[i].count(item)) common++;
}
if (common > max_common) {
max_common = common;
index = j+1;
} else if (common == max_common){
index = min(j+1,index);
}
}
if (max_common == 0){
if (i==0) {
index = 2;
} else {
index = 1;
}
}
cout << index << " " <<max_common << endl;
}
return 0;
}
06-04
3713

03-12
3908
