#include <bits/stdc++.h>

using namespace std;

int main()
{
    map<string, int> mp;
    string w, word;
    while (cin >> word) {
        mp[word]++;
        if (w.size() < word.size()) {
            w = word;
        }
    }
    
    for (auto &x: mp) {
        word = x.first;
    }
    cout << word << " " << w << endl;
    return 0;
}