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

int main() {
    map<string,int> cnt;
    string s,ans1,ans2;
    int mx1=0,mx2=0;
    while (cin>>s) {
        cnt[s]++;
        if (cnt[s]>mx1) {
            mx1=cnt[s];
            ans1=s;
        }
        if (s.size()>mx2) {
            mx2=s.size();
            ans2=s;
        }
    }
    cout<<ans1<<' '<<ans2<<endl;
    return 0;
}
