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

int main(){
    string s, longest="";
    map<string, int> mp;
    while(cin >> s){
        mp[s]++;
        if(longest.size() < s.size())
            longest = s;
    }
    int maxi=0;
    string mode="";
    for(auto e : mp){
        if(e.second > maxi){
            maxi = e.second;
            mode = e.first;
        }
    }
    cout << mode << " " << longest << endl;

    return 0;
}
