#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
unsigned long long n;
cin >> n;
vector<unsigned long long> inputs;
for(unsigned long long i = 0; i < n/2 + 1; i++)
{
unsigned long long a = 0;
cin >> a;
inputs.push_back(a);
cin >> a;
inputs.push_back(a);
}
bool f1 = false, f2 = false;
for(unsigned long long i = 0; i < n/2 + 1; i++){
for(unsigned long long o = 0; o < n/2 + 1; o++){
if(o != i){
if(inputs[o * 2] == inputs[i * 2])
{
f1 = true;
}
else if(inputs[o * 2 + 1] == inputs[i * 2])
{
f1 = true;
}
else if(inputs[o * 2] == inputs[i * 2 + 1])
{
f2 = true;
}
else if(inputs[o * 2 + 1] == inputs[i * 2 + 1])
{
f2 = true;
}
}
}
if(f1 == true && f2 == true)
{
cout << inputs[o * 2] << " " << inputs[o * 2 + 1] << "\n";
return 0;
}
}
return 0;
}