#include<iostream>
using namespace std;
const int N = 100010;
int a[N];
int main(){
int n, max = -99999, min = 100010;
cin >> n;
while(n --){
int t;
while(cin >> t){
if(t < min) min = t;
if(t > max) max = t;
a[t] ++;
}
}
int c, d;
for(int i = min; i <= max; i ++){
if(!a[i]) d = i;
if(a[i] == 2) c = i;
}
printf("%d %d\n", d, c);
return 0;
}