using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
struct word{
	string spell;
	int count;
};
int main()
{
	vector<word> w;
	string s;
	while(cin>>s){
		bool find=false;
		for(int i=0;i<(int)w.size();i++){
			//cout<<"OK"<<endl;
			word* tmp=&w.at(i);
			if(tmp->spell==s){
				tmp->count++;
				find=true;
				break;
			}
		}
		if(find)continue;
		word a={s,1};
		w.push_back(a);
	}
	cout<<"OK"<<endl;
	string l="";
	word m={"",0};
	for(int i=0;i<(int)w.size();i++){
		word tmp=w.at(i);
		if(tmp.count>m.count)m=tmp;
		if(tmp.spell.length()>l.length())l=tmp.spell;
	}
	cout<<m.spell<<" "<<l<<endl;
    return 0;
}