#define rep(i, a, n) for (int i = a; i < n; ++i) #define per(i, a, n) for (int i = n - 1; i >= a; --i) #define fi first #define se second #define pb push_back #define np next_permutation #define mp make_pair #define endl '\n'
structnode { string s; int id; }; node a[maxn];
boolcmp(node a, node b) { if (a.s.length() != b.s.length()) { return a.s.length() > b.s.length(); } else { int len = a.s.length(); rep(i, 0, len) { if (a.s[i] != b.s[i]) return a.s[i] > b.s[i]; } } } int n; string ss; intmain() { ios::sync_with_stdio(false); while (cin >> n) { rep(i, 1, n + 1) { cin >> ss; a[i].s = ss; a[i].id = i; } sort(a + 1, a + 1 + n, cmp); cout << a[1].id << endl << a[1].s << endl; } }