1. 

/**
* FWP: Ausgewaehlte Probleme aus dem ACM (SS10)
*
* Problem: 11784 - Escape
* Method: simulation
* Accepted: 0.564
* @author Evgeni Pavlidis
*
*/

import java.io.*;
import java.util.*;


public class Main {

private static int l;

private static int pos(int p)
{
return (p%l + l) % l;
}

public static void main(String...args)
{
Scanner scanner = new Scanner(System.in);
int m,n,h,d;
int x,y, X,Y;
int saveD, saveTime;
int c;

while(true)
{
m = scanner.nextInt();
n = scanner.nextInt();
h = scanner.nextInt();
if(m == 0)
break;

l = 2*m + 2*n - 4;
boolean[] a = new boolean[l];

// read doors positions
for(int door=0; door < h; door++)
{
y = scanner.nextInt();
x = scanner.nextInt();

if( x == n-1 || y == 0)
a[x+y] = true;
else
a[l-(x+y)] = true;
}

// read MIB position
Y = scanner.nextInt();
X = scanner.nextInt();


// check north
c=0;
while(!a[pos(X-Y-c)])
c++;

saveD = Y;
saveTime = c+saveD;

// check south
c=0;
while(!a[pos(2*n-X+Y-2-c)])
c++;

d = (m-Y-1);
if(c+d < saveTime || (c+d == saveTime && d < saveD))
{
saveD = d;
saveTime = d + c;
}

// check east
c=0;
while(!a[pos(X+Y-c)])
c++;

d = (n-X-1);
if(c+d < saveTime || (c+d == saveTime && d < saveD))
{
saveD = d;
saveTime = d + c;
}

// check west
c=0;
while(!a[pos(l-Y-X-c)])
c++;

if(c+X < saveTime || (c+X == saveTime && X < saveD))
{
saveD = X;
saveTime = X+c;
}

System.out.println((saveTime + 1) + " " + (saveD+1));
}
}
}