#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    string s1 = "1", s2 = "2";
    map<string, int>cnt;
    for(string s;cin >> s;){
        cnt[s]++;
        if(cnt[s] > cnt[s1])s1 = s;
        if(s.size() > s2.size())s2 = s;
    }    
    cout << s1 << " " << s2 << endl;

    return 0;
}
