#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    map<string, int> dic;
    string str, sfmax, slmax, tmp;
    int fmax = 0, lmax = 0;
    getline(cin, tmp);
    stringstream stream(tmp);
    while (getline(stream, str, ' ')){
    	dic[str]++;
    	if (fmax < dic[str]){
    		fmax = dic[str];
    		sfmax = str;
    	}
    	if (lmax < str.length()){
    		lmax = str.length();
    		slmax = str;
    	}
    }
    cout << sfmax << ' ' << slmax << endl;
}
