#include <iostream>
#include <map>
using namespace std;
#define F first
#define S second
int main(){
    string s,ans,lon;
    map<string,int>m;
    int top=0;
    while(cin>>s){
        m[s]++;
        if(s.size()>lon.size())lon=s;
    }
    for(pair<string,int> i:m){
        if(i.S>top){
            top=i.S;
            ans=i.F;
        }
    }
    cout<<ans<<' '<<lon<<endl;
}
