import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    auto s = split(readln());
    string res1,res2;
    int c;
    foreach(i ; s){
	int count = -1;
	foreach(j ; s){
	    if(i == j)count++;
	}
	if(c < count) res1 = i;
	if(i.length > res2.length) res2 = i;
    }
    writef("%s %s\n",res1,res2);
}