#include<bits/stdc++.h>
using namespace std;

int main(){
    map<string,int>M;
    string in,ma,ma2;
    while(cin>>in){
        for(int i=0;i<in.size();i++)in[i]=tolower(in[i]);
        M[in]++;
        if(ma.size()<in.size())ma=in;
    }

    for(map<string,int>::iterator it=M.begin();it!=M.end();it++){
        ma2=it->first;
    }
    cout<<ma2<<" "<<ma<<endl;

    return 0;
}