#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    vector<string> s;
    string tmps;
    set<string> st;
    //int i = 0;
    size_t maxl = 0;
    while(cin >>tmps) {
        s.push_back(tmps);
        st.insert(tmps);
        //maxl = max(maxl, s.at(i).size());
        //i++;
        //cout << tmp;
    }
    
    int ans = 0, maxv = 0;
    string maxs ="";
    string maxL = "";
    for (auto ss : st) {
        int tmp = 0;
        rep(i, s.size()) {
            //int tmp = 0;
            if (ss == s.at(i)) {
                tmp++;
            }
        }
        if (maxv < tmp) {
            maxv = tmp;
            maxs = ss;
        }
        if (maxL.size() < ss.size()) {
            maxL = ss;
        }
    }

    cout << maxs << " " <<maxL << endl;
}
