#include<bits/stdc++.h>
using namespace std;
int main(){
int i,j,n,w,m,min;
int a[100][100];
min=INT_MAX;
cin>>i>>j;
cin>>n;
int x,y;
for(x=0;x<n;x++)
for(y=0;y<2;y++) cin>>a[x][y];
for(x=0;x<n;x++){
if(abs(i+j)-(a[x][0]+a[x][1])<min){
w=a[x][0];
m=a[x][1];
cout<<w<<" "<<m;}}
return 0;
}
/**************************************************************
Problem: 1347
User: wtq001
Language: C++
Result: Wrong Answer
****************************************************************/