#include <bits/stdc++.h>
using namespace std;
typedef struct {
string vote;
int sub;
int len;
} votes;
bool com(votes a, votes b) {
if (a.len > b.len) return true;
else if (a.len == b.len) return a.vote.compare(b.vote);
else return false;
}
int main(void) {
int n;
votes v[20];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> v[i].vote;
v[i].sub = i + 1;
v[i].len = v[i].vote.length();
}
sort(v, v + n, com);
cout << v[0].sub << '\n' << v[0].vote << endl;
return 0;
}
#3和#4过不去