#include <bits/stdc++.h>

using namespace std;

int main(void) {
  map<string, int> mp;
  string s, max_len = "";
  while (cin >> s) {
    mp[s]++;
    if (s.size() > max_len.size()) {
      max_len = s;
    }
  }

  string max_cnt = "";
  for (auto i : mp) {
    if (i.second > mp[max_cnt]) {
      max_cnt = i.first;
    }
  }

  cout << max_cnt << " " << max_len << endl;

  return 0;
}
