#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
string x;
int num;
int lenx;
}s[25];
inline bool cmp(node a, node b)
{
if (a.lenx > b.lenx) return 1;
if (a.lenx == b.lenx && a.x > b.x) return 1;
return 0;
}
inline string read() {
string a;
char ch = getchar();
while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
while (ch != ' ' && ch != '\r' && ch != '\n') {
a += ch;
ch = getchar();
}
return a;
}
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
s[i].x = read();
s[i].num = i;
s[i].lenx = s[i].x.size();
}
sort(s + 1, s + n + 1, cmp);
cout << s[1].num << endl;
cout << s[1].x << endl;
return 0;
}