#include<iostream>
#include<string>
using namespace std;

int main() {
	string str[1000],tmp;
	int a[1000] = {}, flag = 0, max = 1, i, length = 0, num = 0;

	while (cin >> tmp) {
		if (flag == 0) {
			flag++;
			tmp[0] = tmp[0] + 'a' - 'A';
		}
		for (i = 0; i < max;i++) {
			if (tmp == str[i]) {
				a[i]++;
				break;
			}
		}

		if (i == max) {
			str[i] = tmp;
			max++;
		}

		if ((int)tmp.size() > length) {
			num = i;
			length = (int)tmp.size();
		}
	}

	cout << str[max] << " " << str[length] << endl;
	return 0;
}