import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scn = new Scanner(new File("input.txt"));
        BufferedWriter out = new BufferedWriter(new FileWriter("output.txt"));

        int r = scn.nextInt();
        int c = scn.nextInt();

        int[][] a = new int[r][c];

        for(int[] i: a)
            Arrays.fill(i, 1<<30);

        int k = scn.nextInt();

        Queue<State> q = new LinkedList<State>();
        for(int l = 0; l < k; l++){
            int i = scn.nextInt()-1;
            int j = scn.nextInt()-1;

            a[i][j] = 0;
            q.add(new State(i, j, 0));
        }

        while(!q.isEmpty()){
            State st = q.poll();

            a[st.i][st.j] = st.c;

            for(int d = 0; d < 4; d++){
                int ii = st.i + di[d];
                int jj = st.j + dj[d];

                if(ii < 0 || ii >= r || jj < 0 || jj >= c)continue;
                if(a[ii][jj] != 1 << 30)continue;

                a[ii][jj] = st.c+1;
                q.add(new State(ii, jj, st.c+1));
            }
        }

        int max = 0;
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                max = Math.max(max, a[i][j]);

        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                if(a[i][j] == max){
//                  System.out.println(i+1 + " " + (j+1));
                    out.write((i+1)+" "+(j+1));
                    out.newLine();

                    out.close();

                    return;
                }

    }
    static int[] di = {0, 0, -1, 1};
    static int[] dj = {1, -1, 0, 0};
}

class State{
    int i, j, c;
    public State(int ii, int ji, int ci){
        i = ii;
        j = ji;
        c = ci;
    }
}


import java.io.*;
import java.util.*;
public class CF_35C {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new FileReader("input.txt"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));

        StringTokenizer st1 = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st1.nextToken());
        int m = Integer.parseInt(st1.nextToken());

        boolean[][] visited = new boolean[n][m];

        int k = Integer.parseInt(f.readLine());
        LinkedList<state1> ll = new LinkedList<state1>();
        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < k; i++) {
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());

            ll.add(new state1(x - 1, y - 1));
            visited[x - 1][y - 1] = true;
        }

        int lastx = 1;
        int lasty = 1;
        while(!ll.isEmpty()) {
            state1 focus = ll.remove();
            lastx = focus.x+1;
            lasty = focus.y+1;

            //System.out.println(lastx + " " + lasty);

            visited[focus.x][focus.y] = true;
            if(focus.x+1 < n && !visited[focus.x+1][focus.y]) {
                ll.add(new state1(focus.x+1, focus.y));
                visited[focus.x+1][focus.y] = true;
            }
            if(focus.x-1 >= 0 && !visited[focus.x-1][focus.y]) {
                ll.add(new state1(focus.x-1, focus.y));
                visited[focus.x-1][focus.y] = true;
            }
            if(focus.y+1 < m && !visited[focus.x][focus.y+1]) {
                ll.add(new state1(focus.x, focus.y+1));
                visited[focus.x][focus.y+1] = true;
            }
            if(focus.y-1 >= 0 && !visited[focus.x][focus.y-1]) {
                ll.add(new state1(focus.x, focus.y-1));
                visited[focus.x][focus.y-1] = true;
            }
        }
        out.println(lastx + " " + lasty);
        out.close();
    }
}

class state1 {
    int x, y;
    state1(int x, int y) {
        this.x = x; this.y = y;
    }
}


import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class ProblemD {

    static int n;
    static int m;
    static boolean[][] fire;

    public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(new File("input.txt"));
        n = sc.nextInt();
        m = sc.nextInt();
        int k = sc.nextInt();
        fire = new boolean[n][m];
        Queue<Pos> q = new LinkedList<Pos>();
        for (int i = 0; i < k; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            q.add(new Pos(x - 1, y - 1));
            fire[x - 1][y - 1] = true;
        }
        int[] di = new int[] { 1, -1, 0, 0 };
        int[] dj = new int[] { 0, 0, 1, -1};
        Pos last = null;
        while (q.size() > 0) {
            Pos pos = q.poll();
            last = pos;
            for (int kk = 0; kk < 4; kk++) {
                int ni = pos.i + di[kk];
                int nj = pos.j + dj[kk];
                if (ni >= 0 && nj >= 0 && ni < n && nj < m) {
                    if (!fire[ni][nj]) {
                        fire[ni][nj] = true;
                        q.add(new Pos(ni, nj));
                    }
                }
            }
        }
        PrintWriter out = new PrintWriter(new File("output.txt"));
        out.println((last.i + 1) + " " + (last.j + 1));
        out.flush();
        out.close();
    }

}

class Pos {

    int i, j;

    public Pos(int i, int j) {
        super();
        this.i = i;
        this.j = j;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + i;
        result = prime * result + j;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pos other = (Pos) obj;
        if (i != other.i)
            return false;
        if (j != other.j)
            return false;
        return true;
    }

};


import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.util.ArrayDeque;
import java.io.PrintWriter;
import java.io.FileInputStream;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream;
		try {
			inputStream = new FileInputStream("input.txt");
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		OutputStream outputStream;
		try {
			outputStream = new FileOutputStream("output.txt");
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		PandaScanner in = new PandaScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		C solver = new C();
		solver.solve(1, in, out);
		out.close();
	}
}

class C {
    final int dx[] = { -1, 0, 1, 0};
    final int dy[] = { 0, -1, 0, 1};
    final int SHIFT = 15;
    final int COLUMN_MASK = (1 << SHIFT) - 1;
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        boolean burning[][] = new boolean[n][m];
        int k = in.nextInt();
        ArrayDeque<Integer> q = new ArrayDeque<>();
        for (int i = 0; i < k; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            burning[x][y] = true;
            q.add((x << SHIFT) + y);
        }
        int last = 0;
        while (!q.isEmpty()) {
            last = q.poll();
            int x = last >> SHIFT;
            int y = last & COLUMN_MASK;
            for (int d = 0; d < 4; d++) {
                int nx = x + dx[d];
                int ny = y + dy[d];
                if (nx >= 0 && nx < n && ny >= 0 && ny < m && !burning[nx][ny]) {
                    burning[nx][ny] = true;
                    q.add((nx << SHIFT) + ny);
                }
            }
        }
        out.printf("%d %d\n", (last >> SHIFT) + 1, (last & COLUMN_MASK) + 1);
    }
}

class PandaScanner {
    public BufferedReader br;
    public StringTokenizer st;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    public String next() {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(nextLine().trim());
            return next();
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }


import java.util.ArrayList;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.*;
 public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException
    {
        Scanner sc = new Scanner(new File("input.txt"));

        int n = sc.nextInt();
        int m =sc.nextInt();
        sc.nextLine();
        int k =sc.nextInt();
        int les[][] = new int[n][m];
        PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        //sc.nextLine();
        ArrayList<Integer[]> list = new ArrayList();
        sc.nextLine();
        for(int i = 0;i<k;i++)
        {

            Integer[] ii = new Integer[2];
            ii[0] = sc.nextInt()-1;
            ii[1] = sc.nextInt()-1;
            list.add(ii);

        }
        sc.close();
        int maxr = 0;
        int maxi = 0;
        int maxj = 0;
        for(int i = 0;i<n;i++)
        {
            for(int j = 0;j<m;j++)
            {
                int minr = 100000;
                int mini = 0;
                int minj = 0;
                for(int f = 0;f<k;f++)
                {
                    Integer[] ii = list.get(f);
                    int ww = Math.abs(ii[0] - i);
                    int hh = Math.abs(ii[1] - j);
                    int r = ww+hh;
                    if(r<minr)
                    {
                        minr = r;
                        mini=i;
                        minj=j;
                    }

                }
                if(maxr<minr&&minr<100000)
                {
                    maxi = mini;
                    maxj = minj;
                    maxr = minr;
                }
            }
        }

        out.print((maxi+1)+" "+(maxj+1));
        out.close();

    }

}


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

public class C{
	public static void main(String args[]) throws Exception{
		Scanner in = new Scanner(new FileReader("input.txt"));
		PrintWriter out = new PrintWriter(new File("output.txt"));

		int N = in.nextInt();
		int M = in.nextInt();
		int K = in.nextInt();

		int[] X = new int[K], Y = new int[K];
		for (int i = 0; i < K; i++){
			X[i] = in.nextInt();
			Y[i] = in.nextInt();
		}

		int d = -1;
		int a = -1; int b = -1;
		for (int i = 1; i <= N; i++)
			for (int j = 1; j <= M; j++){
				int h = Integer.MAX_VALUE;
				for (int p = 0; p < K; p++)
					h = Math.min(h,Math.abs(i-X[p]) + Math.abs(j-Y[p]));
				if (h > d){
					d = h; a = i; b = j;
				}
			}

		out.print(a + " " + b);
		out.close();
	}
}


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

public class Main implements Runnable {

	public void _main() throws IOException {
		int height = nextInt();
		int width = nextInt();
		int k = nextInt();
		int[] r = new int[k];
		int[] c = new int[k];
		for (int i = 0; i < k; i++) {
			r[i] = nextInt() - 1;
			c[i] = nextInt() - 1;
		}
		int res = 0, R = r[0], C = c[0];
		for (int i = 0; i < height; i++)
			for (int j = 0; j < width; j++) {
				int cur = Integer.MAX_VALUE;
				for (int z = 0; z < k; z++)
					cur = Math.min(cur, Math.abs(i - r[z]) + Math.abs(j - c[z]));
				if (res < cur) {
					res = cur;
					R = i;
					C = j;
				}
			}
		out.print((R + 1) + " " + (C + 1));
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	private String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter(new FileWriter("output.txt"));

			_main();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(202);
		}
	}

}


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

public class C
{
   public static void main(String[] args) throws Exception
   {
      new C(new Scanner(new File("input.txt")), new PrintWriter("output.txt"));
   }

   int oo = 987654321;
   int W, H;

   public C(Scanner in, PrintWriter out)
   {
      W = in.nextInt();
      H = in.nextInt();

      int[][] grid = new int[W][H];
      for (int[] gri : grid)
         Arrays.fill(gri, oo);

      ArrayDeque<Node> q = new ArrayDeque<Node>();
      int K = in.nextInt();
      for (int u=0; u<K; u++)
      {
         q.add(new Node(in.nextInt()-1, in.nextInt()-1, 0));
         while (q.size() > 0)
         {
            Node cur = q.poll();
            if (grid[cur.x][cur.y] <= cur.d)
               continue;
            grid[cur.x][cur.y] = cur.d;
            if (cur.x+1<W)
               q.add(new Node(cur.x+1, cur.y, cur.d+1));
            if (cur.x>0)
               q.add(new Node(cur.x-1, cur.y, cur.d+1));
            if (cur.y+1<H)
               q.add(new Node(cur.x, cur.y+1, cur.d+1));
            if (cur.y>0)
               q.add(new Node(cur.x, cur.y-1, cur.d+1));
         }
      }

      int res = 0;
      for (int j=0; j<H; j++)
         for (int i=0; i<W; i++)
            res = Math.max(res, grid[i][j]);

      for (int j=0; j<H; j++)
         for (int i=0; i<W; i++)
            if (res == grid[i][j])
            {
               out.printf("%d %d%n", i+1, j+1);
               out.close();
               return;
            }
   }
}

class Node
{
   int x, y, d;

   public Node(int xx, int yy, int dd)
   {
      x=xx; y=yy; d=dd;
   }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.Queue;
public class Solution{
    static int[] dx = {1,-1,0,0};
    static int[] dy = {0,0,1,-1};
    static Queue<Pair> q ;
    static boolean[][] visited ;
    static Pair result = new Pair(0,0);
    static int n,m,k;
    public static void main(String[] args){
        try(BufferedReader in = new BufferedReader(new FileReader("input.txt"));
                BufferedWriter out = new BufferedWriter(new FileWriter("output.txt")))
        {
            StringTokenizer s = new StringTokenizer(in.readLine());
            n = Integer.parseInt(s.nextToken());
            m = Integer.parseInt(s.nextToken());
            k = Integer.parseInt(in.readLine());
            visited = new boolean[n][m];
            q = new LinkedList <>();
            s = new StringTokenizer(in.readLine());
            for(int i=0;i<k;i++){
                int x = Integer.parseInt(s.nextToken());
                int y = Integer.parseInt(s.nextToken());
                q.add(new Pair(--x,--y));
            }
            bfs();
            String ans = "" + (result.x+1) +" "+ (result.y+1);
            out.write(ans);
        }catch(IOException e){

        }
    }
    static void bfs(){
        while(!q.isEmpty()){
            Pair temp = q.poll();
            if(visited[temp.x][temp.y]) continue;
            visited[temp.x][temp.y] = true;
            result.x = temp.x;
            result.y= temp.y;
            for(int i=0;i<4;i++){
                int x = temp.x + dx[i];
                int y = temp.y + dy[i];
                if(x>=0 && x<n && y>=0 && y<m && !visited[x][y])
                    q.add(new Pair(x,y));
            }

        }
    }

}
class Pair{
    int x,y;
    public Pair(int x,int y){
        this.x=x;
        this.y=y;
    }
}


import java.awt.Point;
import java.util.LinkedList;
import java.util.Queue;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		Scanner scan = new Scanner("input.txt");
		PrintWriter out = new PrintWriter(new FileWriter("output.txt"));

		int n,m;
		n = scan.nextInt();
		m = scan.nextInt();

		boolean visited[][] = new boolean[n][m];

		int numOfStartingPoints;
		numOfStartingPoints = scan.nextInt();

		int resX = 0, resY = 0;

		Queue<Point> que = new LinkedList<Point>();
		for (int i = 0; i < numOfStartingPoints; i++) {
			int x = scan.nextInt() - 1;
			int y = scan.nextInt() - 1;
			que.add(new Point(x, y));
			visited[x][y] = true;
		}

		while (true) {
			Point current = que.poll();

			if (current == null) {
				break;
			} else {
				resX = current.x;
				resY = current.y;

				if (current.x + 1 < n && !visited[current.x + 1][current.y])
				{
					que.add(new Point(current.x + 1, current.y));
					visited[current.x + 1][current.y] = true;

				}
				if (current.y + 1 < m && !visited[current.x][current.y + 1])
				{
					que.add(new Point(current.x, current.y + 1));
					visited[current.x][current.y + 1] = true;

				}
				if (current.x - 1 >= 0 && !visited[current.x - 1][current.y])
				{
					que.add(new Point(current.x - 1, current.y));
					visited[current.x - 1][current.y] = true;

				}
				if (current.y - 1 >= 0 && !visited[current.x][current.y - 1])
				{
					que.add(new Point(current.x, current.y - 1));
					visited[current.x][current.y - 1] = true;

				}

			}
		}

		out.printf("%d %d\n", ++resX, ++resY);
		out.close();

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}
	}
}


import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

@SuppressWarnings("unchecked")
public class P35C {

  final static int SHIFT = 11;
  final static int MASK = (1 << SHIFT) - 1;
  final static int [] DX = {-1, 1,  0, 0};
  final static int [] DY = { 0, 0, -1, 1};

  public void run() throws Exception {
    int m = nextInt();
    int n = nextInt();

    boolean [][] burned = new boolean [n][m];
    List<Integer> burn = new ArrayList();
    for (int k = nextInt(); k > 0; k--) {
      int x = nextInt() - 1;
      int y = nextInt() - 1;
      burned[y][x] = true;
      burn.add((x << SHIFT) | y);
    }

    int lastXY = 0;
    List<Integer> newBurn = null;
    do {
      lastXY = burn.get(0);
      newBurn = new ArrayList();

      for (int xy : burn) {
        int x = xy >> SHIFT;
        int y = xy & MASK;

        for (int i = 0; i < 4; i++) {
          int nx = x + DX[i];
          int ny = y + DY[i];

          if ((ny >= 0) && (ny < n) && (nx >= 0) && (nx < m) && (!burned[ny][nx])) {
            burned[ny][nx] = true;
            newBurn.add((nx << SHIFT) | ny);
          }
        }
      }

      burn = newBurn;
    } while (newBurn.size() > 0);

    println(((lastXY >> SHIFT) + 1) + " " + ((lastXY & MASK) + 1));
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
    pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream("output.txt")));
    new P35C().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }
}


import java.util.*;
import java.io.*;
import java.awt.Point;

public class Main{
	public static void main(String[] args)throws FileNotFoundException,IOException{
		File file = new File("input.txt");
		Scanner sc = new Scanner(file);
		File outFile = new File("output.txt");
		PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(outFile)));

		int w = sc.nextInt();
		int h = sc.nextInt();
		boolean[][] map = new boolean[h+1][w+1]; //false:�u�G�v���ĂȂ�

		int x = -1, y = -1;
		Queue<Point> open = new LinkedList<Point>();
		int k = sc.nextInt();
		for(int i=0;i<k;i++){
			int tx = sc.nextInt();
			int ty = sc.nextInt();
			map[ty][tx] = true;
			x = tx;
			y = ty;
			open.add(new Point(x,y));
		}

		int dx[] = {1,-1,0,0};
		int dy[] = {0,0,1,-1};
		while(!open.isEmpty()){
			Point p = open.poll();

			for(int i=0;i<4;i++){
				int nx = p.x + dx[i];
				int ny = p.y + dy[i];

				if(nx>0 && nx<=w && ny>0 && ny<=h && !map[ny][nx]){
					map[ny][nx] = true;
					x = nx;
					y = ny;
					open.add(new Point(nx,ny));
				}
			}
		}

		pw.println(x + " " + y);

		pw.close();
	}
}


import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

@SuppressWarnings("unchecked")
public class P35C {

  final static int [] DX = {-1, 1,  0, 0};
  final static int [] DY = { 0, 0, -1, 1};

  public void run() throws Exception {
    int m = nextInt();
    int n = nextInt();

    boolean [][] burned = new boolean [n][m];
    List<Integer> burn = new ArrayList();
    for (int k = nextInt(); k > 0; k--) {
      int x = nextInt() - 1;
      int y = nextInt() - 1;
      burned[y][x] = true;
      burn.add(x * 10000 + y);
    }

    int lastXY = 0;
    List<Integer> newBurn = null;
    do {
      lastXY = burn.get(0);
      newBurn = new ArrayList();

      for (int xy : burn) {
        int x = xy / 10000;
        int y = xy % 10000;

        for (int i = 0; i < 4; i++) {
          int nx = x + DX[i];
          int ny = y + DY[i];

          if ((ny >= 0) && (ny < n) && (nx >= 0) && (nx < m) && (!burned[ny][nx])) {
            burned[ny][nx] = true;
            newBurn.add(nx * 10000 + ny);
          }
        }
      }

      burn = newBurn;
    } while (newBurn.size() > 0);

    println((lastXY / 10000 + 1) + " " + (lastXY % 10000 + 1));
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
    pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream("output.txt")));
    new P35C().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }
}


import java.awt.Point;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class FireAgain {

	Point coordinate;
	Queue<Point> q = new LinkedList<Point>();
	int m, n;
	boolean[][] arr;
	PrintStream out ;

	void bfs(Point start) {

		while (!q.isEmpty()) {
			Point front = q.poll();
			Point p = new Point();

			p.x = front.x - 1;
			p.y = front.y;
			if (p.x >= 1 && p.x <= n && p.y <= m && p.y >= 1) {
				if (!arr[p.x][p.y]) {
					arr[p.x][p.y] = true;
					q.add(p);
				}
			}

			p = new Point();
			p.x = front.x + 1;
			p.y = front.y;
			if (p.x >= 1 && p.x <= n && p.y <= m && p.y >= 1)
				if (!arr[p.x][p.y]) {
					arr[p.x][p.y] = true;
					q.add(p);
				}

			p = new Point() ;
			p.x = front.x;
			p.y = front.y + 1;
			if (p.x >= 1 && p.x <= n && p.y <= m && p.y >= 1)
				if (!arr[p.x][p.y]) {
					arr[p.x][p.y] = true;
					q.add(p);
				}

			p = new Point() ;
			p.x = front.x;
			p.y = front.y - 1;
			if (p.x >= 1 && p.x <= n && p.y <= m && p.y >= 1)
				if (!arr[p.x][p.y]) {
					arr[p.x][p.y] = true;
					q.add(p);
				}

			if (q.size() == 0)
				out.print(front.x + " " + front.y);
		}
	}

	/**
	 * @param args
	 * @throws FileNotFoundException
	 */
	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		FireAgain fa = new FireAgain();
		Scanner Scan = new Scanner(new FileInputStream("input.txt"));
		fa.out = new PrintStream(new File("output.txt"));
		fa.n = Scan.nextInt();
		fa.m = Scan.nextInt();
		int k = Scan.nextInt();
		fa.arr = new boolean[2001][2001];

		for (int i = 0; i < k; i++) {
			fa.coordinate = new Point();
			fa.coordinate.x = Scan.nextInt();
			fa.coordinate.y = Scan.nextInt();
			fa.q.add(fa.coordinate);
			fa.arr[fa.coordinate.x][fa.coordinate.y] = true;
		}

		fa.bfs(fa.q.peek());

	}

}


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

public class C {
	public static void main(String[] args) throws Exception {
		final int fuck = 2001;

		Scanner in = new Scanner(new File("input.txt"));
		PrintWriter out = new PrintWriter(new File("output.txt"));

		int n = in.nextInt(), m = in.nextInt();
		int[] D = new int[ fuck*fuck ],
			dx = new int[] { 1, -1, 0, 0},
			dy = new int[] { 0, 0, -1, 1};
		Arrays.fill(D, -1);

		ArrayDeque<Integer> Q = new ArrayDeque<>();
		int k = in.nextInt(), ans = 0;
		for(int i = 0; i < k; ++i) {
			int x = in.nextInt(), y = in.nextInt();
			D[ans = (x * fuck + y)] = 0;
			Q.offer(ans);
		}

		while(!Q.isEmpty()) {
			int idx = Q.poll();
			int x = idx / fuck, y = idx % fuck;
			for(int i = 0; i < 4; ++i) {
				int wtf = (dx[i] + x) * fuck + (dy[i] + y);
				if(dx[i] + x <= n && dx[i] + x >= 1 && dy[i] + y <= m && dy[i] + y >= 1 && D[wtf] == -1) {
					D[wtf] = D[idx] + 1;
					Q.offer(wtf);

					if(D[wtf] >= D[ans])
						ans = wtf;
				}
			}
		}

		out.println((ans / fuck) + " " + (ans % fuck));
		out.close();
		in.close();
	}
}


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		Scanner read = new Scanner(new FileInputStream(new File("input.txt")));
		PrintWriter out = new PrintWriter(new File("output.txt"));
		int n = read.nextInt(), m = read.nextInt(), k = read.nextInt(), tree[][] = new int[n][m], a[] = new int[k],
				b[] = new int[k], x = 0, y = 0, max = -1, d = 0;

		for (int i = 0; i < k; i++) {
			a[i] = read.nextInt() - 1;
			b[i] = read.nextInt() - 1;
			tree[a[i]][b[i]] = 0;
		}
		for(int i = 0; i < n; i++){
			Arrays.fill(tree[i], Integer.MAX_VALUE);
		}
		for (int o = 0; o < k; o++) {
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					d = Math.abs(a[o] - i) + Math.abs(b[o] - j);
					if(d < tree[i][j])
						tree[i][j] = d;
				}
			}
		}
		for(int i = 0; i<n; i++){
			for(int j = 0; j < m ; j ++){
				if(tree[i][j] > max){
					max=  tree[i][j];
					x=  i;
					y = j;
				}
			}
		}
		out.println(x + 1 + " " + (y + 1));
		out.close();
	}

}


import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;

@SuppressWarnings("unused")
public class Fire35C {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	int mod = (int)(Math.pow(10,9)+7);
	int v = 0;
	int max = 0;
	StringBuilder st = new StringBuilder();
	File outFile = new File("output.txt");
	void solve() throws IOException
	{

		int n = ni();
		int m = ni();

		boolean visited[][] = new boolean[n][m];
		boolean inq[][] = new boolean[n][m];
		Queue<Integer> x = new LinkedList<>();
		Queue<Integer> y = new LinkedList<>();
		Queue<Integer> lev = new LinkedList<>();

		int a = -1 , b = -1 , max = 0;

		int k = ni();
		while(k-- > 0) {
			int u = ni()-1;
			int v = ni()-1;
			x.add(u);
			y.add(v);
			lev.add(1);
			inq[u][v] = true;
		}

		while(x.size() != 0) {

			int u = x.poll();
			int v = y.poll();
			int l = lev.poll();
			if(max < l) {
				a = u;
				b = v;
				max = l;
			}
			visited[u][v] = true;
			if(u-1 >= 0 && !visited[u-1][v] && !inq[u-1][v]) {
				x.add(u-1);
				y.add(v);
				lev.add(l+1);
				inq[u-1][v] = true;
			}

			if(u+1 < n && !visited[u+1][v] && !inq[u+1][v]) {
				x.add(u+1);
				y.add(v);
				lev.add(l+1);
				inq[u+1][v] = true;
			}

			if(v-1 >= 0 && !visited[u][v-1] && !inq[u][v-1]) {
				x.add(u);
				y.add(v-1);
				lev.add(l+1);
				inq[u][v-1] = true;
			}

			if(v+1 < m && !visited[u][v+1] && !inq[u][v+1]) {
				x.add(u);
				y.add(v+1);
				lev.add(l+1);
				inq[u][v+1] = true;
			}

		}
		a++;
		b++;

		out.println(a+" "+b);
		out.close();
	}

	void run() throws Exception
	{
		is = INPUT.isEmpty() ? new FileInputStream(new File("input.txt")) : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(new BufferedWriter(new FileWriter(outFile)));

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new Fire35C().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b) && b != ' ')){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int[][] na(int n , int m)
	{
		int[][] a = new int[n][m];
		for(int i = 0;i < n;i++)
			for(int j = 0 ; j<m ; j++) a[i][j] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void display2D(int a[][]) {
		for(int i[] : a) {
			for(int j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	int[][] creategraph(int n , int m) {
		int g[][] = new int[n+1][];

		int from[] = new int[m];
		int to[] = new int[m];
		int ct[] = new int[n+1];

		for(int i = 0 ; i<m; i++) {
			from[i] = ni();
			to[i] = ni();
			ct[from[i]]++;
			ct[to[i]]++;
		}

		int parent[] = new int[n+1];

		for(int i = 0 ; i<n+1 ; i++) g[i] = new int[ct[i]];

		for(int i = 0 ; i<m ; i++) {
			g[from[i]][--ct[from[i]]] = to[i];
			g[to[i]][--ct[to[i]]] = from[i];
		}

		return g;
	}

	static long __gcd(long a, long b)
	{

		if(b == 0)
		{
			return a;
		}
		else
		{
			return __gcd(b, a % b);
		}
	}

	// To compute x^y under modulo m
	static long power(long x, long y, long p)
	{

		// Initialize result
		long res = 1;

		// Update x if it is more than or
		// equal to p
		x = x % p;

		while (y > 0)
		{

			// If y is odd, multiply x
			// with result
			if (y % 2 == 1)
				res = (res * x) % p;

			// y must be even now
			y = y >> 1; // y = y/2
		x = (x * x) % p;
		}

		return res;
	}

	// Function to find modular
	// inverse of a under modulo m
	// Assumption: m is prime
	static long modInverse(long a, int m)
	{
		if (__gcd(a, m) != 1) {
			//System.out.print("Inverse doesn't exist");
			return -1;
		}

		else {

			// If a and m are relatively prime, then
			// modulo inverse is a^(m-2) mode m
			//			System.out.println("Modular multiplicative inverse is "
			//											+power(a, m - 2, m));
			return power(a, m - 2, m);
		}
	}

	static long nCrModPFermat(int n, int r,
			int p , long fac[])
	{

		// Base case
		if (r == 0)
			return 1;

		// Fill factorial array so that we
		// can find all factorial of r, n
		// and n-r
		long t = (fac[n]* modInverse(fac[r], p))%p;

		return ( (t* modInverse(fac[n-r], p))% p);
	}

	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}


import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream;
        try
        {
            inputStream = new FileInputStream("input.txt");
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        OutputStream outputStream;
        try
        {
            outputStream = new FileOutputStream("output.txt");
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        private final static int[] dx = {-1, 0, +1, 0};
        private final static int[] dy = {0, +1, 0, -1};
        private final static int WHITE = 123456789;

        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int m = in.nextInt();

            int[][] map = new int[n][m];
            for (int i = 0; i < n; i++)
            {
                Arrays.fill(map[i], WHITE);
            }

            int k = in.nextInt();

            int qh = 0;
            int qt = 0;
            int[] q = new int[((int) 7e6)];
            for (int i = 0; i < k; i++)
            {
                int x = in.nextInt() - 1;
                int y = in.nextInt() - 1;
                map[x][y] = 0;
                q[qh++] = x * m + y;
            }

            int d = 0;
            int X = q[0] / m;
            int Y = q[0] % m;
            while (qt < qh)
            {
                int pos = q[qt++];
                int x = pos / m;
                int y = pos % m;
                for (int i = 0; i < 4; i++)
                {
                    int xx = x + dx[i];
                    int yy = y + dy[i];
                    if (isValid(xx, n) && isValid(yy, m) && map[xx][yy] == WHITE)
                    {
                        map[xx][yy] = map[x][y] + 1;
                        q[qh++] = (xx * m) + yy;
                        if (d < map[xx][yy])
                        {
                            d = map[xx][yy];
                            X = xx;
                            Y = yy;
                        }
                    }
                }
            }
//        for (int i = 0; i < n; i++)
//        {
//            for (int j = 0; j < m; j++)
//            {
//                out.print(map[i][j] + " ");
//            }
//            out.println();
//        }
            out.println((X + 1) + " " + (Y + 1));
        }

        private boolean isValid(int x, int X)
        {
            return x >= 0 && x < X;
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}


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

public class Main {

    static boolean used[][];
    static int n;
    static int m;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new FileReader("input.txt"));
        PrintWriter out = new PrintWriter("output.txt");
        n = nextInt();
        m = nextInt();
        int k = nextInt();
        used = new boolean[n][m];
        Deque<point> deq = new ArrayDeque<>();
        for (int i = 0; i < k; i++) {
            deq.addLast(new point(nextInt() - 1, nextInt() - 1));
            used[deq.peekLast().x][deq.peekLast().y] = true;
        }
        point last = new point(0, 0);
        while (!deq.isEmpty()) {
            point v = deq.pollFirst();
            int x = v.x;
            int y = v.y;
            if (checker(x, y + 1)) {
                last = new point(x, y + 1);
                deq.addLast(new point(x, y + 1));
                used[x][y + 1] = true;
            }
            if (checker(x, y - 1)) {
                last = new point(x, y - 1);
                deq.addLast(new point(x, y - 1));
                used[x][y - 1] = true;
            }
            if (checker(x + 1, y)) {
                last = new point(x + 1, y);
                deq.addLast(new point(x + 1, y));
                used[x + 1][y] = true;
            }
            if (checker(x - 1, y)) {
                last = new point(x - 1, y);
                deq.addLast(new point(x - 1, y));
                used[x - 1][y] = true;
            }
        }
        out.println(last.x + 1 + " " + (last.y + 1));
        out.close();
    }

    static boolean checker(int x, int y) {
        if (x < n && y < m && x >= 0 && y >= 0 && !used[x][y]) return true;
        return false;
    }

    static StringTokenizer st = new StringTokenizer("");
    static BufferedReader br;

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

class point {
    int x, y;

    public point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader//(new InputStreamReader(System.in));
                                            (new FileReader("input.txt"));
        StringBuilder out = new StringBuilder();
        StringTokenizer tk;
        PrintWriter pw = new PrintWriter("output.txt", "UTF-8");

        int [] dx = {-1,1,0,0},dy = {0,0,-1,1};

        tk = new StringTokenizer(in.readLine());
        int n = parseInt(tk.nextToken()),m = parseInt(tk.nextToken());
        int k = parseInt(in.readLine());

        int [][] dist = new int[n][m];
        for(int i=0; i<n; i++)
            Arrays.fill(dist[i], -1);

        int ans = -1,atx = -1,aty = -1;

        Queue<point> q = new LinkedList<point>();

        tk = new StringTokenizer(in.readLine());
        while(k-- > 0) {
            int x = parseInt(tk.nextToken())-1,y = parseInt(tk.nextToken())-1;

            dist[x][y] = 0;
            q.add(new point(x,y));
        }

        while(!q.isEmpty()) {
            point p = q.remove();

            if(dist[p.x][p.y]>ans) {
                ans = dist[p.x][p.y];
                atx = p.x+1;
                aty = p.y+1;
            }

            for(int i=0; i<4; i++) {
                int nx = p.x + dx[i];
                int ny = p.y + dy[i];

                if(nx>=0 && nx<n && ny>=0 && ny<m && dist[nx][ny]==-1) {
                    dist[nx][ny] = dist[p.x][p.y] + 1;
                    q.add(new point(nx,ny));
                }
            }
        }

        pw.println(atx+" "+aty);
        pw.close();
    }

}

class point {
    int x,y;

    public point(int x,int y) {
        this.x = x;
        this.y = y;
    }
}


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

public class practice {

		public static void main(String[] args) throws FileNotFoundException {
			Scanner scn = new Scanner(new FileReader("input.txt"));
			PrintWriter out = new PrintWriter(new File("output.txt"));
		 int n=scn.nextInt(),m=scn.nextInt(),k=scn.nextInt();
		 int[][] inf=new int[k][2];
		 for(int i=0;i<k;i++){
			 inf[i][0]=scn.nextInt();inf[i][1]=scn.nextInt();
		 }
		 int ans=0,x=1,y=1;
		 for(int i=1;i<=n;i++){
			 for(int j=1;j<=m;j++){
				 int temp=Integer.MAX_VALUE;
				 for(int l=0;l<k;l++){
					temp=Math.min(temp, Math.abs(i-inf[l][0])+Math.abs(j-inf[l][1]));
				 }
				 if(temp>ans){
					 ans=temp;x=i;y=j;
				 }
			 }
		 }
		 out.print(x+ " " + y);
	   	 out.close();
		}
	}


import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        PrintWriter pw = new PrintWriter(new FileWriter("output.txt"));
        Scanner in=new Scanner(new File("input.txt"));
        int n,m,k;
        n=in.nextInt();
        m=in.nextInt();
        k=in.nextInt();
        Vector<Integer> vec=new Vector<Integer>();
        Vector<Integer> temp=new Vector<Integer>();
        boolean[][] mas=new boolean[n][m];
        long time=System.currentTimeMillis();
        for(int i=0;i<k;i++)
        {
            vec.add(in.nextInt()-1);
            vec.add(in.nextInt()-1);
            mas[vec.get(vec.size()-2)][vec.get(vec.size()-1)]=true;
        }
        int x,y;
        x=y=0;
        while(vec.size()!=0)
        {
            for(int i=0;i<vec.size();i+=2)
            {
                x=vec.get(i);
                y=vec.get(i+1);
                if(x>0 && !mas[x-1][y])
                {
                    temp.add(x-1);
                    temp.add(y);
                    mas[x-1][y]=true;
                }
                if(x<n-1 && !mas[x+1][y])
                {
                    temp.add(x+1);
                    temp.add(y);
                    mas[x+1][y]=true;
                }
                if(y>0 && !mas[x][y-1])
                {
                    temp.add(x);
                    temp.add(y-1);
                    mas[x][y-1]=true;
                }
                if(y<m-1 && !mas[x][y+1])
                {
                    temp.add(x);
                    temp.add(y+1);
                    mas[x][y+1]=true;
                }
            }
            vec=temp;
            temp=new Vector<Integer>();
        }
        pw.println((x+1)+" "+(y+1));
        System.out.println(System.currentTimeMillis()-time);
        in.close();
        pw.close();
    }
}


import java.awt.*;
import java.io.*;
import java.util.*;
import java.util.Queue;

public class A {

    static int[] dx = {-1, 0, 1, 0};
    static int[] dy = {0, 1, 0, -1};

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner("input.txt");
        PrintWriter out = new PrintWriter("output.txt");
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
        int[][] dist = new int[n][m];
        for(int[] a : dist) Arrays.fill(a, -1);
        Queue<Point> q = new LinkedList<>();
        for(int i = 0; i < k; i++)
        {
            int x = sc.nextInt() - 1, y = sc.nextInt() - 1;
            dist[x][y] = 0;
            q.add(new Point(x, y));
        }
        int ansX = -1, ansY = -1;
        while(!q.isEmpty())
        {
            Point cur = q.remove();
            ansX = cur.x; ansY = cur.y;
            for(int i = 0; i < 4; i++)
            {
                int x = cur.x + dx[i], y = cur.y + dy[i];
                if(x != -1 && y != -1 && x != n && y != m && dist[x][y] == -1)
                {
                    q.add(new Point(x, y));
                    dist[x][y] = dist[cur.x][cur.y] + 1;
                }
            }
        }
        out.println((ansX + 1) + " " + (ansY + 1));
        out.flush();
        out.close();
    }
    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {br = new BufferedReader(new InputStreamReader(system));}
        public Scanner(String file) throws Exception {br = new BufferedReader(new FileReader(file));}
        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public String nextLine()throws IOException{return br.readLine();}
        public int nextInt() throws IOException {return Integer.parseInt(next());}
        public double nextDouble() throws IOException {return Double.parseDouble(next());}
        public char nextChar()throws IOException{return next().charAt(0);}
        public Long nextLong()throws IOException{return Long.parseLong(next());}
        public boolean ready() throws IOException{return br.ready();}
        public void waitForInput() throws InterruptedException {Thread.sleep(4000);}
    }
}


import java.io.*;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeSet;

public class ViewAngle{
		        	private static int V,level[][],count=-1,lev_dfs[],degree=0,no_vert_conn_comp=0;
		        	private static Stack <Integer>st=new Stack();
		        	private static LinkedList<Integer > adj[];
		        	private static boolean[][] Visite;
		        	private static boolean [] Visited;
		        	private static TreeSet<Integer> ts=new TreeSet();
		        //	private static HashMap
		        	private static Queue<Pair> queue = new LinkedList<Pair>();
		        	ViewAngle(int V){
		    V++;
		    this.V=(V);
		    adj=new LinkedList[V];
		    Visite=new boolean[100][100];

	 	   Visited=new boolean[V];

		   lev_dfs=new int[V];
		   for(int i=0;i<V;i++)
			   adj[i]=new LinkedList<Integer>();
		    }
		        	static File inFile,outFile;
		        	static FileWriter fWriter;
		        	static PrintWriter pWriter;
		        	public static void main(String[] args) throws IOException {

		    	 inFile=new File("input.txt");
		    	 outFile = new File ("output.txt");
			     fWriter = new FileWriter (outFile);
			    pWriter = new PrintWriter (fWriter);
			  Scanner sc = new Scanner (inFile);
			  int n=sc.nextInt();
			  int m=sc.nextInt();
			  char c[][]=new char[n][m];
			  for(int i=0;i<n;i++){
				  for(int j=0;j<m;j++){
					  c[i][j]='.';
				  }
			  }
			  setup(n, m);
			  int k=sc.nextInt();
			  for(int i=0;i<k;i++){
				  int x=sc.nextInt();
				  int y=sc.nextInt();
				  queue.add(new Pair(x-1, y-1));
				  c[x-1][y-1]='X';
			 level[x-1][y-1]=-1;
			 Visite[x-1][y-1]=true;
			  }
			BFS(c, n, m);
		    	pWriter.close();
		    	sc.close();
		    }
		   static  void addEdge(int v,int w){

		    	if(adj[v]==null){
		    		adj[v]=new LinkedList();
		    	}
		    	adj[v].add(w);

		    }

		    public static int BFS2(int startVert,int dest){
		    	Visited=new boolean[V];
		    	for(int i=1;i<V;i++){
		    		lev_dfs[i]=-1;
		    	}
		    	Queue<Integer> q=new LinkedList<Integer>();
		    	q.add(startVert);

		    	lev_dfs[startVert]=0;
		    	while(!q.isEmpty()){
		    		int top=q.poll();

		    		Iterator<Integer> i= adj[top].listIterator();
		    		while(i.hasNext()){
		    			int n=i.next();
		    			if(!Visited[n]){
		    				q.add(n);
		    				Visited[n]=true;
		    				lev_dfs[n]=lev_dfs[top]+1;
		    			if(n==dest){
		    				q.clear();
		    				return lev_dfs[n];

		    			}
		    			}
		    		}
		    	}
		    	q.clear();
		    	return -1;
		    }
		    public int getEd(){
		    	return degree/2;
		    }
		    public void get(int from,int to){
		    	int h=lev_dfs[from]-lev_dfs[to];
		    	if(h<=0){
		    		System.out.println(-1);
		    	}else{
		    		System.out.println(h-1);
		    	}
		    }
		    public static void setup(int n,int m){

		    	 level=new int[n][m];
		    	Visite=new boolean[n][m];
		    }
		    private static boolean check(int x,int y,char c[][]){

				if((x>=0 && y>=0) && (x<c.length && y<c[0].length) && c[x][y]=='.'){

					return true;
				}
				return false;
			}
		    public static int BFS(char[][] c,int n,int m)
		    {
		        //Visited[s]=true;
		   //     queue.add(new Pair(x,y));
		       int count=0;
		 //  level[x][y]=-1;
		        while (!queue.isEmpty())
		        {

		            Pair temp = queue.poll();
		           int  x=temp.w;
		            int y=temp.h;
		            Visite[x][y]=true;
		            if(check(x+1,y,c) && !Visite[x+1][y]){
		            	level[x+1][y]=level[x][y]+1;
		            	queue.add(new Pair(x+1, y));
		            Visite[x+1][y]=true;
		            }
		            if(check(x-1,y,c) && !Visite[x-1][y]){
		            	level[x-1][y]=level[x][y]+1;
		            	queue.add(new Pair(x-1, y));
		            	Visite[x-1][y]=true;
		            }
		            if(check(x,y+1,c) && !Visite[x][y+1]){
		            	level[x][y+1]=level[x][y]+1;
		            	queue.add(new Pair(x, y+1));
		            	Visite[x][y+1]=true;
		            }
		            if(check(x,y-1,c) && !Visite[x][y-1]){
		            	level[x][y-1]=level[x][y]+1;
		            	queue.add(new Pair(x, y-1));
		            	Visite[x][y-1]=true;
		            }

		        }
		        int prev_lev=-1,x=-1,y=-1;
		        for(int i=0;i<n;i++){
		        	for(int j=0;j<m;j++){
		        		if(level[i][j]>=prev_lev){
		        			prev_lev=level[i][j];
		        			x=i;y=j;
		        		}
		        		//System.out.println(level[i][j]+" ");
		        	}
		        	//System.out.println();
		        }

		        pWriter.println((x+1)+" "+(y+1));
		        return V;
		    }

		    private void getAns(int startVertex){
		    	for(int i=0;i<adj[startVertex].size();i++){
		    		int ch=adj[startVertex].get(i);
		    		for(int j=0;j<adj[ch].size();j++){
		    			int ch2=adj[ch].get(j);
		    			if(adj[ch2].contains(startVertex)){
		    				System.out.println(startVertex+" "+ch+" "+ch2);
		    				System.exit(0);
		    			}
		    		}
		    	}
		    }

		     public long dfs(int startVertex){
		    //	 getAns(startVertex);

		    	 if(!Visited[startVertex])  {

		   return dfsUtil(startVertex,Visited);
		    	//return getAns();
		    	}

		    return 0;
		    	}
		 private long dfsUtil(int startVertex, boolean[] Visited) {//0-Blue 1-Pink
		//System.out.println(startVertex);
			 int c=1;
			 long cout=0;
		      degree=0;
		    	Visited[startVertex]=true;
		    //	lev_dfs[startVertex]=1;
		      st.push(startVertex);
		    while(!st.isEmpty()){

		    	int top=st.pop();

		   	Iterator<Integer> i=adj[top].listIterator();
		     degree+=adj[top].size();

		    while(i.hasNext()){
		// System.out.println(top+" "+adj[top].size());
		    	int n=i.next();
		  //  	System.out.print(n+" ");
		     if( !Visited[n]){
		    				Visited[n]=true;
		    					st.push(n);
		    				//	System.out.print(n+" ");
		    					lev_dfs[n]=top;

		    		 }
		         }
		//    System.out.println("--------------------------------");
		 }

		    for(int i=1;i<V;i++){
		    	if(lev_dfs[i]!=0){
		    		System.out.print(lev_dfs[i]+" ");
		    	}
		    }
		    return cout;

		  //  System.out.println("NO");
		   // return c;

		    }

		        }
class Pair implements Comparable<Pair>{

	int w;
	int h;
	Pair(int w,int h){
		this.w=w;
		this.h=h;
	}
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
	//	Sort in increasing order
		if(w>o.w){
			return 1;
		}else if(w<o.w){
			return -1;
		}else{
			if(h>o.h)
				return 1;
			else if(h<o.h)
				return -1;
			else
			return 0;
		}

	}

}


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

public class Main {
    public static void main(String[] args) throws IOException {
        //InputStream input = System.in;
        //OutputStream output = System.out;
        InputReader in = new InputReader(new FileReader(new File("input.txt")));
        PrintWriter out = new PrintWriter(new FileWriter(new File("output.txt")));
        //InputReader in = new InputReader(input);
        //PrintWriter out = new PrintWriter(output);
        Solution s = new Solution();
        s.solve(1, in, out);
        out.close();
    }

    static class Solution {

        double EPS = 0.0000001;
        public void solve(int cs, InputReader in, PrintWriter out) {

            int n = in.nextInt(), m = in.nextInt();
            Graph g = new Graph(n, m);
            int k = in.nextInt();
            for (int[] v : g.vis)
                Arrays.fill(v, -1);
            while (k-- > 0) {
                Pair start = new Pair(in.nextInt()-1, in.nextInt()-1);
                g.bfs(start);
            }
            int idx1 = 0, idx2 = 0, max = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; ++j) {
                    if (g.vis[i][j] > max) {
                        idx1 = i;
                        idx2 = j;
                        max = g.vis[i][j];
                    }
                }
            }
            out.println((idx1+1) + " " + (idx2+1));
        }

        static class Pair {
            int x, y;

            public Pair(int x, int y) {
                this.x = x ;
                this.y = y;
            }
        }

        static class Graph {
            LinkedList<Integer> adj[];
            int n, e;
            int[][] vis;

            @SuppressWarnings("unchecked")
            public Graph(int n, int e) {
                this.n = n;
                this.e = e;
                adj = new LinkedList[n];
                for (int i = 0; i < n; ++i)
                    adj[i] = new LinkedList<>();
                vis = new int[n][e];
            }

            int[] dx = {0, 0, 1, -1};
            int[] dy = {1, -1, 0, 0};

            void bfs(Pair src) {
                Queue<Pair> q = new LinkedList<>();
                vis[src.x][src.y] = 0;
                q.add(src);
                while (!q.isEmpty()) {
                    Pair p = q.poll();
                    for (int k = 0; k < 4; k++) {
                        int ni = p.x+dx[k];
                        int nj = p.y+dy[k];
                        if (isValid(ni, nj) && (vis[ni][nj] == -1 || vis[p.x][p.y]+1 < vis[ni][nj])) {
                            vis[ni][nj] = vis[p.x][p.y]+1;
                            q.add(new Pair(ni, nj));
                        }
                    }

                }
            }

            boolean isValid(int i, int j) {
                return i >= 0 && i < n && j >= 0 && j < e;
            }
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i), 32768);
            st = null;
        }

        public InputReader(FileReader s) {
            br = new BufferedReader(s);
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
        public Reader(){
            din=new DataInputStream(System.in);
            buffer=new byte[BUFFER_SIZE];
            bufferPointer=bytesRead=0;
        }

        public Reader(String file_name) throws IOException{
            din=new DataInputStream(new FileInputStream(file_name));
            buffer=new byte[BUFFER_SIZE];
            bufferPointer=bytesRead=0;
        }

        public String readLine() throws IOException{
            byte[] buf=new byte[64]; // line length
            int cnt=0,c;
            while((c=read())!=-1){
                if(c=='\n')break;
                buf[cnt++]=(byte)c;
            }
            return new String(buf,0,cnt);
        }

        public int nextInt() throws IOException{
            int ret=0;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c=read();
            do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(neg)return -ret;
            return ret;
        }

        public long nextLong() throws IOException{
            long ret=0;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c=read();
            do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(neg)return -ret;
            return ret;
        }

        public double nextDouble() throws IOException{
            double ret=0,div=1;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c = read();
            do {ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(c=='.')while((c=read())>='0'&&c<='9')
                ret+=(c-'0')/(div*=10);
            if(neg)return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException{
            bytesRead=din.read(buffer,bufferPointer=0,BUFFER_SIZE);
            if(bytesRead==-1)buffer[0]=-1;
        }

        private byte read() throws IOException{
            if(bufferPointer==bytesRead)fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException{
            if(din==null) return;
            din.close();
        }
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A {

	static final int[] dx = {0, 0, -1, 1};
	static final int[] dy = {-1, 1, 0, 0};

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner("input.txt");
		PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
//		Scanner sc = new Scanner(System.in);
//		PrintWriter out = new PrintWriter(System.out);

		int N = sc.nextInt(), M = sc.nextInt();
		int[][] dist = new int[N][M];
		Queue<Integer> q = new LinkedList<>();
		int K = sc.nextInt();
		while(K-->0)
		{
			int x = sc.nextInt() - 1, y = sc.nextInt() - 1;
			q.add(x * M + y);
			dist[x][y] = 1;
		}

		int max = 0, ansX = -1, ansY = -1;
		while(!q.isEmpty())
		{
			int u = q.remove(), x = u / M, y = u % M;
			if(dist[x][y] > max)
				max = dist[ansX = x][ansY = y];
			for(int k = 0; k < 4; ++k)
			{
				int nx = x + dx[k], ny = y + dy[k];
				if(nx >= 0 && ny >= 0 && nx < N && ny < M && dist[nx][ny] == 0)
				{
					dist[nx][ny] = dist[x][y] + 1;
					q.add(nx * M + ny);
				}

			}
		}
		out.printf("%d %d\n", ansX + 1, ansY + 1);
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}
	}
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class P35C {
	public static void main(String[] args) throws FileNotFoundException {
		InputStream inputStream = new FileInputStream("input.txt");
		OutputStream outputStream = new FileOutputStream("output.txt");
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}

	static class Task {
		private class Point {
			int x, y;

			public Point(int x, int y) {
				this.x = x;
				this.y = y;
			}

		}

		private int dis(int i, int j, Point p2) {
			return Math.abs(i - p2.x) + Math.abs(j - p2.y);
		}

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt(), m = in.nextInt();
			int k = in.nextInt();
			Point[] ps = new Point[k];
			for (int i = 0; i < k; i++) {
				ps[i] = new Point(in.nextInt() - 1, in.nextInt() - 1);
			}
			int max = 0;
			Point argmax = ps[0];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					int val = dis(i, j, ps[0]);
					for (int l = 1; l < k; l++) {
						val = Math.min(val, dis(i, j, ps[l]));
					}
					if (val > max) {
						max = val;
						argmax = new Point(i, j);
					}
				}
			}
			out.println((argmax.x + 1) + " " + (argmax.y + 1));
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}

}


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x35C
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(infile.readLine());
         int[][] grid = new int[N][M];
         for(int i=0; i < N; i++)
            Arrays.fill(grid[i], -1);
         ArrayDeque<Integer> q = new ArrayDeque<Integer>();
         st = new StringTokenizer(infile.readLine());
         while(K-->0)
         {
            int a = Integer.parseInt(st.nextToken())-1;
            int b = Integer.parseInt(st.nextToken())-1;
            grid[a][b] = 0;
            q.add(a);   q.add(b);
         }
         while(q.size() > 0)
         {
            int x = q.poll();
            int y = q.poll();
            if(x > 0 && grid[x-1][y] == -1)
            {
               grid[x-1][y] = grid[x][y]+1;
               q.add(x-1); q.add(y);
            }
            if(y > 0 && grid[x][y-1] == -1)
            {
               grid[x][y-1] = grid[x][y]+1;
               q.add(x);   q.add(y-1);
            }
            if(x+1 < N && grid[x+1][y] == -1)
            {
               grid[x+1][y] = grid[x][y]+1;
               q.add(x+1); q.add(y);
            }
            if(y+1 < M && grid[x][y+1] == -1)
            {
               grid[x][y+1] = grid[x][y]+1;
               q.add(x);   q.add(y+1);
            }
         }
         int r = 0;
         int c = 0;
         for(int i=0; i < N; i++)
            for(int j=0; j < M; j++)
               if(grid[r][c] < grid[i][j])
               {
                  r = i;
                  c = j;
               }
         r++;  c++;
         System.setOut(new PrintStream(new File("output.txt")));
         System.out.println(r+" "+c);
      }
   }


import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static InputStream IN;
    public static OutputStream OUT;
    public static PrintWriter out;
    public static BufferedReader in;

    public static StringTokenizer st = null;
    public static int ni() throws Exception {
        for (;st == null || !st.hasMoreTokens();){
            st = new StringTokenizer(in.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }
    public static void main(String[] args) throws Exception {
        IN = new FileInputStream("input.txt");
        OUT = new FileOutputStream("output.txt");
        out = new PrintWriter(OUT);
        in = new BufferedReader(new InputStreamReader(IN));
        int n = ni();
        int m = ni();
        int k = ni();
        int[] x = new int[k];
        int[] y = new int[k];
        for (int i = 0 ; i < k; i++){
            x[i] = ni() - 1;
            y[i] = ni() - 1;
        }
        int w = Integer.MIN_VALUE;
        int aa = -1;
        int ab = -1;
        for (int i = 0 ; i < n ; i++){
            for (int j = 0; j < m; j++){
                int min = Integer.MAX_VALUE;
                for (int q = 0; q < k; q++){
                    int cur = Math.abs(i - x[q]) + Math.abs(j - y[q]);
                    min = Math.min(cur, min);
                }
                if (min > w){
                    w = min;
                    aa = i;
                    ab = j;
                }
            }
        }
        out.println((aa + 1) + " " + (ab + 1));

        out.flush();
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream input = System.in;
        OutputStream output = System.out;
        InputReader in = new InputReader(new FileReader(new File("input.txt")));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        Solution s = new Solution();
        s.solve(1, in, out);
        out.close();
    }

    static class Solution {

        static int[][] grid;
        static int[] dx = {0, 0, 1, -1};
        static int[] dy = {1, -1, 0, 0};
        static int n, m;
        public void solve(int cs, InputReader in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            int k = in.nextInt();
            grid = new int[n][m];
            for (int[] d : grid)
                Arrays.fill(d, -1);
            for (int i = 0; i < k; i++) {
                Pair tree = new Pair(in.nextInt()-1, in.nextInt()-1);
                bfs(tree);
            }
            int max = 0, idx1 = 0, idx2 = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (grid[i][j] > max) {
                        max = grid[i][j];
                        idx1 = i;
                        idx2 = j;
                    }
                }
            }
            out.printf("%d %d%n", idx1+1, idx2+1);

        }
        public boolean isValid(int i, int j) {
            return i >= 0 && i < n && j >= 0 && j < m;
        }

        static class Pair {
            int x, y;
            public Pair(int x, int y) {
                this.x = x;
                this.y = y;
            }
        }
        public void bfs(Pair src) {
            Queue<Pair> q = new LinkedList<>();
            grid[src.x][src.y] = 0;
            q.add(src);
            while (!q.isEmpty()) {
                Pair p = q.poll();
                for (int k = 0; k < 4; k++) {
                    int nx = p.x+dx[k];
                    int ny = p.y+dy[k];
                    if (isValid(nx, ny)) {
                        if (grid[nx][ny] > grid[p.x][p.y]+1 || grid[nx][ny] == -1) {
                            grid[nx][ny] = grid[p.x][p.y] + 1;
                            q.add(new Pair(nx, ny));
                        }
                    }
                }
            }
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i), 32768);
            st = null;
        }

        public InputReader(FileReader s) {
           br = new BufferedReader(s);
           st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }

}


import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * @author igor_kz
 */
public class C35 {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(new File("input.txt"));
        PrintWriter out = new PrintWriter("output.txt");
        int n = in.nextInt() , m = in.nextInt();
        int k = in.nextInt();
        int[] x = new int[k];
        int[] y = new int[k];
        int res = 0;
        for (int i = 0 ; i < k ; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
        }
        int xx = 1 , yy = 1;
        for (int i = 1 ; i <= n ; i++)
            for (int j = 1 ; j <= m ; j++) {
                int cnt = Integer.MAX_VALUE;
                for (int l = 0 ; l < k ; l++) {
                    int time = Math.abs(i - x[l]) + Math.abs(j - y[l]);
                    cnt = Math.min(cnt , time);
                }
                if (cnt > res) {
                    res = cnt;
                    xx = i;
                    yy = j;
                }
                res = Math.max(res , cnt);
            }
        out.print(xx + " " + yy);
        out.close();
    }
}


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

public class Main{

	public static void main(String[] Args) throws Exception {
	     Scanner sc = new Scanner(new FileReader("input.txt"));
	     int n,m,k;
	     Integer lx,ly;
	     boolean d[][];
	     n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt();
	     d = new boolean [n+1][m+1];
	     for(int i=0;i<=n;++i)
	      for(int j=0;j<=m;++j)
	       d[i][j]=false;

	     Queue< pair > q = new LinkedList< pair >();
	     lx = ly = -1;
	     for(int i=0;i<k;++i){
	     	int x,y; x = sc.nextInt(); y = sc.nextInt();
	     	q.add(new pair(x,y)); lx = x; ly = y;
	     	d[x][y]=true;
	     }

	     int dx [] = {0,0,1,-1};
	     int dy [] = {-1,1,0,0};

	     while(!q.isEmpty()){
	     	 pair tp = q.remove();
	     	 int x = tp.x; int y = tp.y;
	     	 for(int i=0;i<4;++i){
	     	 	 int nx = x+dx[i]; int ny = y+dy[i];
	     	 	 if(nx<1 || nx>n || ny<1 || ny>m || d[nx][ny] ) continue;
	     	     d[nx][ny]=true;
	     	     q.add(new pair(nx,ny));
	     	     lx = nx; ly = ny;
	     	 }
	     }
	     FileWriter fw = new FileWriter("output.txt");
	     fw.write(lx.toString()); fw.write(" "); fw.write(ly.toString());;
	     fw.flush();

	}
}
class pair {

  public int x,y;
  public pair(int _x,int _y){ x = _x; y = _y; }

}


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

public class C
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		C c = new C(filePath);
	}

	public C(String inputFile)
	{
		inputFile="input.txt";
        openInput(inputFile);
        PrintWriter writer=null;
		try {
			writer = new PrintWriter("output.txt");

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		readNextLine();
		int N=NextInt();
		int M=NextInt();
		readNextLine();
		int K=NextInt();
		readNextLine();
		int [] [] p = new int[N][M];
		int [] [] init = new int [K][2];

		for(int i=0; i<K; i++)
		{
			int x=NextInt()-1;
			int y=NextInt()-1;
			p[x][y]=0;
			init[i][0]=x;
			init[i][1]=y;
		}

		int max=-1;
		int maxX=-1, maxY=-1;

		for(int i=0; i<N; i++)
			for(int j=0; j<M; j++)
			{
				p[i][j]=10000;
				for(int k=0; k<K; k++)
				{
					int n=Math.abs(init[k][0]-i)+Math.abs(init[k][1]-j);
					if(n<p[i][j])p[i][j]=n;
				}
				if(p[i][j]>max)
				{
					max=p[i][j];
					maxX=i+1;
					maxY=j+1;
				}
			}

		writer.println( maxX+" "+maxY);

		closeInput();
		writer.close();
	}

}


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class FireAgain {
    static int dx[] = { 0, 0, 1, -1 };
    static int dy[] = { 1, -1, 0, 0 };

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(new File("input.txt"));
        BufferedWriter write = new BufferedWriter(new FileWriter("output.txt"));
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] v = new boolean[n][m];
        int k = sc.nextInt();
        Queue<Integer> q = new LinkedList<Integer>();
        for (int i = 0; i < k; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            q.add(x);
            q.add(y);
            v[x][y] = true;
        }
        int lastx = 0;
        int lasty = 0;
        while (!q.isEmpty()) {
            lastx = q.poll();
            lasty = q.poll();
            for (int i = 0; i < 4; i++) {
                int r = lastx + dx[i];
                int c = lasty + dy[i];
                if (r >= 0 && c >= 0 && r < n && c < m && !v[r][c]) {
                    v[r][c] = true;
                    q.add(r);
                    q.add(c);
                }
            }
        }
        write.write((lastx + 1) + " " + (lasty + 1));
        write.close();
    }

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new FileReader("input.txt"));

		String dimensions = br.readLine();
		String extractDim = "";
		int n = 0, m;
		for (int i = 0 ; i < dimensions.length() ; i++)
		{
			if(dimensions.charAt(i) == ' ')
			{
				n = Integer.parseInt(extractDim);
				extractDim = "";
				continue;
			}
			extractDim += dimensions.charAt(i);
		}
		m = Integer.parseInt(extractDim);

		String burningTrees = br.readLine();

		int k = Integer.parseInt(burningTrees);

		Point[] coord = new Point[k];

		String coordSet = br.readLine();
		int spaceCount = 0;
		String newCoord = "";
		int s = 0;
		for(int i = 0 ; i < coordSet.length() ; i++)
		{
			if(coordSet.charAt(i) == ' ')
				spaceCount++;

			if(spaceCount == 2)
			{
				String extractCoord = "";
				int x = 0, y;
				for (int j = 0 ; j < newCoord.length() ; j++)
				{
					if(newCoord.charAt(j) == ' ')
					{
						x = Integer.parseInt(extractCoord);
						extractCoord = "";
						continue;
					}
					extractCoord += newCoord.charAt(j);
				}
				y = Integer.parseInt(extractCoord);

				coord[s] = new Point(x,y);
				s++;
				newCoord = "";
				spaceCount = 0;
				continue;
			}

			newCoord += coordSet.charAt(i);
		}

		String extractCoord = "";
		int x = 0, y;
		for (int j = 0 ; j < newCoord.length() ; j++)
		{
			if(newCoord.charAt(j) == ' ')
			{
				x = Integer.parseInt(extractCoord);
				extractCoord = "";
				continue;
			}
			extractCoord += newCoord.charAt(j);
		}
		y = Integer.parseInt(extractCoord);

		coord[s] = new Point(x,y);
		s++;

		br.close();

		int[][] forest = new int[n+2][m+2];

		for(int i = 0 ; i < forest.length ; i++)
		{
			for(int j = 0 ; j < forest[i].length ; j++)
			{
				if(i == 0 || i == n+1 || j == 0 || j == m+1 )
					forest[i][j] = 0;
				else
					forest[i][j] = 1;
			}
		}

		Queue<Point> q = new LinkedList<>();

		for(int i = 0 ; i < coord.length ; i++)
		{
			forest[coord[i].x][coord[i].y] = 0;
			q.add(coord[i]);
		}

		Point tree = new Point();
		while(!q.isEmpty())
		{
			Point temp = q.remove();
			forest[temp.x][temp.y] = 0;

			if(q.isEmpty())
				tree = new Point(temp.x ,temp.y);
			for(int i = -1 ; i <= 1 ; i++)
			{
				for(int j = -1; j <= 1; j++)
				{
					if(i != 0 && j != 0 || i == 0 && j == 0)
						continue;
					if(forest[temp.x+i][temp.y+j] == 0)
						continue;
					else
					{
						forest[temp.x+i][temp.y+j] = 0;
						q.add(new Point(temp.x+i , temp.y+j));
					}
				}
			}

		}

		BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));
		bw.write(tree.x + " " + tree.y);
		bw.close();

	}

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
//import java.util.Scanner;

public class Codes {

	public static void main(String[] args) throws IOException {
		InputReader input = new InputReader(new FileReader(("input.txt")));
		int n = input.nextInt();
		int m = input.nextInt();
		int k = input.nextInt();
		boolean[][] visited = new boolean[n][m];
		Queue<Point> bfs = new LinkedList<Point>();
		for (int i = 0; i < k; i++) {
			int x = input.nextInt();
			int y = input.nextInt();
			visited[x - 1][y - 1] = true;
			bfs.add(new Point(x - 1, y - 1));
		}
		Point last = bfs.peek();
		while(!bfs.isEmpty()) {
			Point current = bfs.poll();
			int curX = current.x;
			int curY = current.y;
			//the upper tree
			if(curX - 1 >= 0) {
				if(!visited[curX - 1][curY]) {
					bfs.add(new Point(curX - 1,curY));
					visited[curX - 1][curY] = true;
				}
			}
			//the tree to the right
			if(curY + 1 < m) {
				if(!visited[curX][curY + 1]) {
					bfs.add(new Point(curX ,curY + 1));
					visited[curX][curY + 1] = true;
				}
			}
			//the lower tree
			if(curX + 1 < n) {
				if(!visited[curX + 1][curY]) {
					bfs.add(new Point(curX + 1,curY));
					visited[curX + 1][curY] = true;
				}
			}
			//the point to the left
			if(curY - 1 >= 0) {
				if(!visited[curX][curY - 1]) {
					bfs.add(new Point(curX ,curY - 1));
					visited[curX][curY - 1] = true;
				}
			}
			if(bfs.peek()!= null)
			last = bfs.peek();
		}
		PrintWriter out = new PrintWriter(new File("output.txt"));
		out.println((last.x + 1) + " " + (last.y + 1));
		out.close();
		//System.out.println((last.x + 1) + " " + (last.y + 1));
	}

	static class Point {
		int x;
		int y;

		public Point(int x2, int y2) {
			x = x2;
			y = y2;

		}
	}

	/**
	 * This reader class is NOT Mine.
	 **/
	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader(FileReader stream) {
			reader = new BufferedReader(stream);
			tokenizer = null;
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


import java.awt.*;
import java.io.*;
import java.util.*;
public class Abc {
    public static void main(String[] args) throws IOException {
//        FastReader sc = new FastReader();
        Scanner sc=new Scanner(new FileReader("input.txt"));
        PrintWriter out=new PrintWriter(new File("output.txt"));
        int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
        boolean vis[][]=new boolean[n][m];
        LinkedList<Integer> q=new LinkedList<>();
        for (int i=0;i<k;i++){
            int x=sc.nextInt()-1,y=sc.nextInt()-1;
            vis[x][y]=true;
            q.add(x);q.add(y);
        }
        int lastx=-1,lasty=-1;
        int dirX[]={1,-1,0,0},dirY[]={0,0,1,-1};
        while (!q.isEmpty()){
            int x=q.removeFirst();
            int y=q.removeFirst();
            lastx=x;lasty=y;
            for (int i=0;i<4;i++){
                int newx=x+dirX[i],newy=y+dirY[i];
                if (newx>=0 && newx<n && newy>=0 && newy<m && !vis[newx][newy]){
                    vis[newx][newy]=true;
                    q.add(newx);q.add(newy);
                }
            }
        }
        out.println((lastx+1)+" "+(lasty+1));
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    static class Point {
        int x;
        int y;

        Point(int a, int b) {
            x = a;
            y = b;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    public static void main(String[] args) throws IOException {
        File f = new File("input.txt");
        Scanner sc = new Scanner(f);
        BufferedWriter bw = new BufferedWriter(new FileWriter(new File("output.txt")));
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] board = new boolean[n][m];
        int count = sc.nextInt();
        Point[] burningTrees = new Point[count];
        for (int i=0; i<count; i++) {
            burningTrees[i] = new Point(sc.nextInt() - 1,sc.nextInt() - 1);
        }
        Point last = findLastPoint(board,burningTrees);
        bw.append((last.x + 1) + " " + (last.y + 1) + "\n");
        bw.flush();
        bw.close();
        sc.close();
    }

    public static Point findLastPoint(boolean[][] board,  Point[] burningTree){
        Queue<Point> queue = new LinkedList<Point>();
        for(int i = 0; i <burningTree.length; i++ ) {
            queue.add(burningTree[i]);
            board[burningTree[i].x][burningTree[i].y] = true;
        }
        Point lastPoint = new Point(-1,-1);
        while (!queue.isEmpty()) {
            Point p = queue.poll();
            lastPoint = p;
            ArrayList<Point> neighbours = getNeighbours(p,board);
            for(int i = 0; i <neighbours.size(); i++ ) {
                queue.add(neighbours.get(i));
                board[neighbours.get(i).x][neighbours.get(i).y] = true;
            }
        }
        return lastPoint;
    }

    public static ArrayList<Point> getNeighbours(Point p, boolean[][] board){
        ArrayList<Point> neighbours = new ArrayList<>();
        for(int i = -1; i <=1; i++ ){
            for(int j = -1; j <= 1; j++ ){
                if(Math.abs(i) != Math.abs(j)) {
                    int x = p.x + i;
                    int y = p.y + j;
                    if (x >= 0 && x < board.length && y >= 0 && y < board[0].length) {
                        if (board[x][y] == false) {
                            neighbours.add(new Point(x,y));
                        }
                    }
                }
            }
        }
        return neighbours;
    }
}


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

public class C implements Runnable {
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	Random rnd;

	short[] qx, qy;
	boolean[][] used;
	final int[] dx = {1, -1, 0, 0};
	final int[] dy = {0, 0, 1, -1};

	void solve() throws IOException {
		int n = nextInt(), m = nextInt();

		qx = new short[n * m];
		qy = new short[n * m];
		used = new boolean[n][m];

		int k = nextInt(), qs = 0, qt = 0;

		for(int i = 0; i < k; i++) {
			int x = nextInt() - 1, y = nextInt() - 1;
			used[x][y] = true;
			qx[qt] = (short) x;
			qy[qt] = (short) y;
			++qt;
		}

		int rx = 0, ry = 0;

		while(qs < qt) {
			int cx = qx[qs], cy = qy[qs];
			++qs;

			rx = cx;
			ry = cy;

			for(int z = 0; z < 4; z++) {
				int nx = cx + dx[z], ny = cy + dy[z];

				if(nx >= 0 && ny >= 0 && nx < n && ny < m && !used[nx][ny]) {
					used[nx][ny] = true;
					qx[qt] = (short) nx;
					qy[qt] = (short) ny;
					++qt;
				}
			}
		}

		out.println((rx + 1) + " " + (ry + 1));
	}

	public static void main(String[] args) {
		final boolean oldChecker = false;

		if(oldChecker) {
			new Thread(null, new C(), "yarrr", 1 << 24).start();
		} else {
			new C().run();
		}
	}

	public void run() {
		try {
			try {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new FileWriter("output.txt"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null) {
				return null;
			}

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}