#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<int,string>> arr;
bool cmp(pair<int, string> a, pair<int, string> b)
{
if (a.second.size() != b.second.size())
return a.second.size() > b.second.size();
return a.second > b.second;
}
int main()
{
int n;
string s;
pair<int, string> a;
cin >> n;
getchar();
int i,j;
for (i = 0; i < n; i++)
{
getline(cin, s);
a.first = i + 1;
a.second = s;
arr.push_back(a);
}
sort(arr.begin(),arr.end(), cmp);
cout << arr[0].first << endl << arr[0].second << endl;
return 0;
}