var
a:array[1..20] of string;
x:string;
i,n,s:integer;
begin
readln(n);
for i:=1 to n do readln(a[i]);
s:=1;
for i:=2 to n do
if (length(a[i])>length(a[1]))or(length(a[i])=length(a[1]))and(a[i]>a[1]) then
begin
s:=i;
x:=a[1];
a[1]:=a[i];
a[i]:=x;
end;
writeln(s);
writeln(a[1]);
end.
a:array[1..20] of string;
x:string;
i,n,s:integer;
begin
readln(n);
for i:=1 to n do readln(a[i]);
s:=1;
for i:=2 to n do
if (length(a[i])>length(a[1]))or(length(a[i])=length(a[1]))and(a[i]>a[1]) then
begin
s:=i;
x:=a[1];
a[1]:=a[i];
a[i]:=x;
end;
writeln(s);
writeln(a[1]);
end.