#include<bits/stdc++.h>
using namespace std;
string d,x,s,k;
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
getline(cin,s);
for(int i=0;i<s.length();i++){
if(s[i]!=' '&&s[i]!=','&&s[i]!='.') k+=s[i];
else k="";
if(d.length()<k.length()) d=k;
if(x==""||(k.length()&&x.length()>k.length())) x=k;
}cout<<d<<"\n"<<x;
return 0;
}
闭关