#include<iostream>
#include<fstream>
using namespace std;
int main(){
int v[201]={0}, x, k=2, y[3], j=1;
ifstream f("bac.in");
while(f>>x) if(x<=98&&x>=10) v[x]=1;
for(int i=98;i>=10;i--) if(v[i]==0&&(i%10!=(i/10)%10)) {k--;y[j++]=i;}
if(k>0) cout<<"nu exista";
else cout<<y[1]<<' '<<y[2];
return 0;
}