import java.util.*;
import java.io.*;
import java.math.*;
public class Main1
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////
    static class pair
    {
       int x;
       int y;
       public pair (int k, int p)
       {
           x = k;
           y = p;
       }
       @Override
       public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            pair pair = (pair) o;
            return x == pair.x && y == pair.y;
        }

       @Override
       public int hashCode() {
            return Objects.hash(x, y);
       }
    }
    public static void main(String[] args)throws IOException
    {
        /*PrintWriter out= new PrintWriter(new File("input.txt"));
        Reader sc=new Reader();*/
        Scanner sc = new Scanner(new File("input.txt"));
		PrintWriter out = new PrintWriter("output.txt");
        Queue<pair> q=new LinkedList<>();
        int n=sc.nextInt();
        int m=sc.nextInt();
        int t=sc.nextInt();
        int mark[][]=new int[n+2][m+2];
        while(t-->0)
        {
            int a=sc.nextInt();int b=sc.nextInt();
            mark[a][b]=1;
            q.add(new pair(a,b));
        }
        int ansx=1;int ansy=1;
        while(q.size()!=0)
        {
            pair p=q.remove();
            if(mark[Math.max(1,p.x-1)][p.y]==0)
            {
                q.add(new pair(Math.max(1,p.x-1),p.y));
                mark[Math.max(1,p.x-1)][p.y]=1;
                ansx=Math.max(1,p.x-1);
                ansy=p.y;
            }
            if(mark[Math.min(n,p.x+1)][p.y]==0)
            {
                q.add(new pair(Math.min(n,p.x+1),p.y));
                mark[Math.min(n,p.x+1)][p.y]=1;
                ansx=Math.min(n,p.x+1);
                ansy=p.y;
            }
            if(mark[p.x][Math.max(1,p.y-1)]==0)
            {
                q.add(new pair(p.x,Math.max(1,p.y-1)));
                mark[p.x][Math.max(1,p.y-1)]=1;
                ansx=p.x;
                ansy=Math.max(1,p.y-1);
            }
            if(mark[p.x][Math.min(m,p.y+1)]==0)
            {
                q.add(new pair(p.x,Math.min(m,p.y+1)));
                mark[p.x][Math.min(m,p.y+1)]=1;
                ansx=p.x;
                ansy=Math.min(m,p.y+1);
            }
        }
        out.println(ansx+" "+ansy);
        out.flush();
    }
}


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

public class MainF {
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new FileReader(new File("input.txt")));
        BufferedWriter bw = new BufferedWriter(new FileWriter(new File("output.txt")));
        String S = br.readLine();
        String[]J = S.split(" ");
        int N = Integer.parseInt(J[0]);
        int M = Integer.parseInt(J[1]);

        int K = Integer.parseInt(br.readLine());
        int[]x = new int[K];
        int[]y = new int[K];
        S = br.readLine();
        J = S.split(" ");
        for(int i = 0; i<2*K; i = i + 2){
            x[i/2] = Integer.parseInt(J[i]);
            y[i/2] = Integer.parseInt(J[i+1]);
        }

        int ans = -1;
        int ansX = -1;
        int ansY = -1;

        for (int i = 1; i<=N; i++){
            for (int j = 1; j<=M; j++){
                int W = M + N;
                for (int k = 0; k<K; k++){
                    W = Math.min(W, Math.abs(i-x[k]) + Math.abs(j-y[k]));
                }
                if (W < ans)continue;
                ans = W;
                ansX = i;
                ansY = j;
            }
        }
        bw.write(Integer.toString(ansX)+" "+Integer.toString(ansY));
        br.close();
        bw.close();
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Collection;
import java.io.FileWriter;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Objects;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Nafiur Rahman Khadem Shafin 🙂
 */
public class Main {
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader (inputStream);
		PrintWriter out = new PrintWriter (outputStream);
		ProblemCFireAgain solver = new ProblemCFireAgain ();
		solver.solve (1, in, out);
		out.close ();
	}

	static class ProblemCFireAgain {
		private static final byte[] dx = {-1, 0, 0, 1};
		private static final byte[] dy = {0, -1, 1, 0};
		private static int[][] lvl;
		private static int max;
		private static int n;
		private static int m;
		private static int k;
		private static ProblemCFireAgain.Pair[] bgn;
		private static ProblemCFireAgain.Pair res;

		private static void bfs2d () {
			Queue<ProblemCFireAgain.Pair> bfsq = new LinkedList<ProblemCFireAgain.Pair> ();
			for (ProblemCFireAgain.Pair src : bgn) {
				lvl[src.a][src.b] = 0;
				bfsq.add (src);
			}
			while (!bfsq.isEmpty ()) {
				ProblemCFireAgain.Pair op = bfsq.poll ();
				int plvl = lvl[op.a][op.b];
//			System.out.println ("ber hoise "+op+" "+plvl);
				if (plvl>max) {
					res = op;
					max = plvl;
				}
				for (int i = 0; i<4; i++) {
					int newX = op.a+dx[i];
					int newY = op.b+dy[i];
//				System.out.println (newX+" "+newY+" "+n+" "+m);
					if (newX>0 && newX<=n && newY>0 && newY<=m && lvl[newX][newY] == -1) {
						bfsq.add (new ProblemCFireAgain.Pair (newX, newY));
						lvl[newX][newY] = (plvl+1);
//					System.out.println ("dhukse "+newX+" "+newY);
					}
				}
			}
		}

		public void solve (int testNumber, InputReader _in, PrintWriter _out) {
			/*
			 * file input-output 😮. Multi source bfs. Same as snackdown problem.
			 * */
			try (InputReader in = new InputReader (new FileInputStream ("input.txt"));
				 PrintWriter out = new PrintWriter (new BufferedWriter (new FileWriter ("output.txt")))) {
				n = in.nextInt ();
				m = in.nextInt ();
				k = in.nextInt ();
				bgn = new ProblemCFireAgain.Pair[k];
				for (int i = 0; i<k; i++) {
					bgn[i] = new ProblemCFireAgain.Pair (in.nextInt (), in.nextInt ());
				}
				max = Integer.MIN_VALUE;
				lvl = new int[n+5][m+5];
				for (int i = 0; i<n+4; i++) {
					Arrays.fill (lvl[i], -1);
				}
				bfs2d ();
//			System.out.println (max);
				out.println (res);
			} catch (Exception e) {
//			e.printStackTrace ();
			}
		}

		private static class Pair {
			int a;
			int b;

			Pair (int a, int b) {
				this.a = a;
				this.b = b;
			}

			public String toString () {
				return a+" "+b;
			}

			public boolean equals (Object o) {
				if (this == o) return true;
				if (!(o instanceof ProblemCFireAgain.Pair)) return false;
				ProblemCFireAgain.Pair pair = (ProblemCFireAgain.Pair) o;
				return a == pair.a && b == pair.b;
			}

			public int hashCode () {
				return Objects.hash (a, b);
			}

		}

	}

	static class InputReader implements AutoCloseable {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

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

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

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

		public void close () throws Exception {
			reader.close ();
		}

	}
}


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

public class C35C_BFS_Fire {
    public static boolean[][] burning;
    public static LinkedList<int[]> LitTrees; //which is best to use
    public static int N, M;
    public static int[] lastTree;
    public static void main(String[] args) throws IOException {
        // InputStreamReader stream = new InputStreamReader(System.in);
        // BufferedReader input = new BufferedReader(stream);

        BufferedReader input = new BufferedReader(new FileReader("input.txt"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));

        StringTokenizer dataR = new StringTokenizer(input.readLine());
        N = Integer.parseInt(dataR.nextToken());
        M = Integer.parseInt(dataR.nextToken());
        burning = new boolean[N+1][M+1];

        StringTokenizer dataR1 = new StringTokenizer(input.readLine());
        int K = Integer.parseInt(dataR1.nextToken());

        StringTokenizer dataR2 = new StringTokenizer(input.readLine());
        LitTrees = new LinkedList<int[]>();
        for (int j = 0; j < K; j++){
            int x = Integer.parseInt(dataR2.nextToken());
            int y = Integer.parseInt(dataR2.nextToken());
            int[] coord = {x, y};
            LitTrees.add(coord);
            burning[x][y] = true;
        }

        // while(ExistsAliveTree()){
        //     spread();
        // }

        spread();

        // System.out.println(LitTrees.getLast()[0] + " " + LitTrees.getLast()[1]);
        out.println(lastTree[0] + " " + lastTree[1]);
        out.close();

    }

    public static void spread(){
        while(!LitTrees.isEmpty()){
            int[] studying = LitTrees.removeFirst(); //is iterator faster
            int[] studying1 = {studying[0]-1, studying[1]};
            int[] studying2 = {studying[0], studying[1]-1};
            int[] studying3 = {studying[0], studying[1]+1};
            int[] studying4 = {studying[0]+1, studying[1]};
            if (studying1[0] >= 1 && !burning[studying1[0]][studying1[1]]){
                LitTrees.add(studying1);
                burning[studying1[0]][studying1[1]] = true;
            }
            if (studying2[1] >= 1 && !burning[studying2[0]][studying2[1]]){
                LitTrees.add(studying2);
                burning[studying2[0]][studying2[1]] = true;
            }
            if (studying3[1] < M+1 && !burning[studying3[0]][studying3[1]]){
                LitTrees.add(studying3);
                burning[studying3[0]][studying3[1]] = true;
            }
            if (studying4[0] < N+1 && !burning[studying4[0]][studying4[1]]){
                LitTrees.add(studying4);
                burning[studying4[0]][studying4[1]] = true;
            }
            lastTree = studying;
        }
    }

    public static boolean ExistsAliveTree() {
        if (LitTrees.size() == N*M){
            return false;
        } else{
            return true;
        }
    }
}


//package round35;

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

public class C {
	Scanner in;
	PrintWriter out;
//	String INPUT = "3 3 1 1 1";
	String INPUT = "";

	void solve()
	{
		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 max = -1;
		int maxi = -1;
		int maxj = -1;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				int min = Integer.MAX_VALUE;
				for(int l = 0;l < k;l++){
					min = Math.min(min, Math.abs(x[l] - i) + Math.abs(y[l] - j));
				}
				if(min > max){
					max = min;
					maxi = i;
					maxj = j;
				}
			}
		}

		out.println((maxi+1) + " " + (maxj+1));
	}

	void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(new File("input.txt")) : new Scanner(INPUT);
		out = INPUT.isEmpty() ? new PrintWriter("output.txt") : new PrintWriter(System.out);

		solve();
		out.flush();
	}

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

	int ni() { return Integer.parseInt(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(o.length > 1 || o[0].getClass().isArray() ? Arrays.deepToString(o) : o[0]); }
	static String join(int[] a, int d){StringBuilder sb = new StringBuilder();for(int v : a){sb.append(v + d + " ");}return sb.toString();}
}


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

public class c {

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

	public static void main(String args[])throws Exception{
		Scanner in =new Scanner(new File("input.txt"));//System.in);//
		PrintWriter out=new PrintWriter(new File("output.txt"));//System.out);//
		n = in.nextInt();
		m = in.nextInt();
		int k = in.nextInt();
		//a=new int[n+1][m+1];
		/*for (int i = 1; i<=n; i++)
			for (int j = 1; j<=m; j++)
				a[i][j] = 40001;
		*/
		int x[]=new int[k];
		int y[]=new int[k];
		for (int i = 0; i<k; i++){
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}

		int max = 0;
		int xx = 1; int yy= 1;
		for (int i = 1; i<=n; i++)
			for (int j = 1; j<=m; j++){
				int count = Integer.MAX_VALUE;
				for (int l =0; l<k; l++)
					count = Math.min(Math.abs(i - x[l]) + Math.abs(j - y[l]), count);

				if (max < count){
					max = count;
					xx = i; yy = j;
				}
			}
		out.println(xx + " " + yy);
		out.close();
	}
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayDeque;
import java.util.Arrays;

public class Main {
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;

    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }

    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }

    static{

        /*
        inB = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        /**/
        //*
        try {
        inB = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        out = new PrintWriter(new FileOutputStream("output.txt"));
        } catch(Exception e) {}
        /**/
        in = new StreamTokenizer(inB);
    }

    private static int[][] mind;
    private static boolean[][] used;

    private static int n,m;

    public static void main(String[] args)throws Exception {
        n = nextInt();
        m = nextInt();
        int k = nextInt();
        int[][] mas = new int[k][2];

        for(int i = 0; i<k; i++) {
            mas[i][0] = nextInt()-1;
            mas[i][1] = nextInt()-1;
        }

        mind = new int[n][m];
        used = new boolean[n][m];
        for(int i = 0; i<n; i++) {
            Arrays.fill(mind[i], Integer.MAX_VALUE);
        }

        ArrayDeque<int[]> ad = new ArrayDeque<int[]>();

        for(int i = 0; i<k; i++) {
            ad.add(new int[] {mas[i][0], mas[i][1], 0});
        }

        while(!ad.isEmpty()) {
            int[] cur = ad.remove();

            if(used[cur[0]][cur[1]])continue;
            int x = cur[0]; int y = cur[1]; int d = cur[2];
            mind[x][y] = ++d;
            used[x][y] = true;
            //if(isValid(x+1,y+1) && !used[x+1][y+1])   ad.add(new int[] {x+1,  y+1, d});
            if(isValid(x+1,y)   && !used[x+1][y])   ad.add(new int[] {x+1,  y,   d});
            //if(isValid(x+1,y-1) && !used[x+1][y-1])   ad.add(new int[] {x+1,  y-1, d});
            if(isValid(x,y+1)   && !used[x][y+1])   ad.add(new int[] {x,    y+1, d});
            if(isValid(x,y-1)   && !used[x][y-1])   ad.add(new int[] {x,    y-1, d});
            //if(isValid(x-1,y+1) && !used[x-1][y+1])   ad.add(new int[] {x-1,  y+1, d});
            if(isValid(x-1,y)   && !used[x-1][y])   ad.add(new int[] {x-1,  y,   d});
            //if(isValid(x-1,y-1) && !used[x-1][y-1])   ad.add(new int[] {x-1,  y-1, d});
        }

        int max = Integer.MIN_VALUE;
        int maxx = 0, maxy = 0;

        for(int i = 0; i<n; i++) {
            for(int j = 0; j<m; j++) {
                if(mind[i][j] > max) {
                    max = mind[i][j];
                    maxx = i+1;
                    maxy = j+1;
                }
            }
        }

        out.println(maxx + " " + maxy);
        out.flush();
    }

    private static boolean isValid(int x, int y) {
        return x>=0 && x<n && y>=0 && y<m;
    }

    /////////////////////////////////////////////////
    // pre - written
    /////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        System.out.println(o);
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    /////////////////////////////////
}


import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		Scanner sc = new Scanner(new File("input.txt"));
		PrintWriter out = new PrintWriter(new File("output.txt"));
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<ArrayList<Integer>> fire = new ArrayList<ArrayList<Integer>>();
		while (k-- != 0) {
			ArrayList<Integer> t = new ArrayList<Integer>();
			t.add(sc.nextInt());
			t.add(sc.nextInt());
			fire.add(t);
		}

		int maxI = 0, maxJ = 0, maxManhatten = -1;
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= m; j++){
				int curManhatten = Integer.MAX_VALUE;
				for(int u = 0; u < fire.size(); u++)
					curManhatten = Math.min(curManhatten, manhatten(i, j, fire.get(u).get(0), fire.get(u).get(1)));

				if(curManhatten > maxManhatten){
					maxManhatten = curManhatten;
					maxI = i;
					maxJ = j;
				}
			}

		out.print(maxI + " " + maxJ);
		out.flush();
		out.close();
	}

	private static int manhatten(int i, int j, Integer a, Integer b) {
		return Math.abs(i - a) + Math.abs(j - b);
	}
}


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

public class practice {
	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();
        }
    }

		public static void main(String[] args) throws IOException {
			Reader scn=new Reader("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.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 *
 * 3 2 3 5
 * -2 -1 4 -1 2 7 3
 *
 * 10 1 -10617 30886 -7223 -63085 47793 -61665 -14614 60492 16649 -58579 3 8 1
 * 10 4 7 1 7 3 7
 *
 * 22862 -34877
 *
 * @author pttrung
 */
public class C_Round_35_Div2 {

    public static long MOD = 1000000007;
    static int[] X = {0, 1, 0, -1};
    static int[] Y = {1, 0, -1, 0};
    static int[][][] dp;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out = new PrintWriter(new FileOutputStream(new File(
                "output.txt")));
        //PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[][] map = new int[n][m];
        LinkedList<Point> q = new LinkedList();
        int reX = -1;
        int reY = -1;
        for (int i = 0; i < k; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            reX = x;
            reY = y;
            map[x][y] = 1;
            q.add(new Point(x, y));
        }

        while (!q.isEmpty()) {
            Point p = q.poll();
            // System.out.println(map[p.x][p.y] + " " + p.x + " " + p.y);
            for (int i = 0; i < 4; i++) {
                int x = p.x + X[i];
                int y = p.y + Y[i];
                if (x >= 0 && y >= 0 && x < n && y < m && map[x][y] == 0) {
                    map[x][y] = 1 + map[p.x][p.y];
                    if (map[x][y] > map[reX][reY]) {
                        reX = x;
                        reY = y;
                    }

                    q.add(new Point(x, y));
                }
            }
        }
        out.println((reX + 1) + " " + (reY + 1));
        out.close();

    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

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

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
           // br = new BufferedReader(new InputStreamReader(System.in));
             br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

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

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


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.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
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int m = in.nextInt();
            int p = in.nextInt();
            int[] x = new int[p];
            int[] y = new int[p];
            for (int i = 0; i < p; i++)
            {
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            int X = x[0];
            int Y = y[0];
            int D = -1;
            for (int dx = 1; dx <= n; dx++)
            {
                int x1 = dx;
                int y1 = 1;
                int xx = 0;
                int yy = 0;
                int minD = Integer.MAX_VALUE;
                for (int j = 0; j < p; j++)
                {
                    int d = Math.abs(x1 - x[j]) + Math.abs(y1 - y[j]);
                    if (d < minD)
                    {
                        minD = d;
                        xx = x1;
                        yy = y1;
                    }
                }
                if (D < minD && minD != 0 && minD != Integer.MAX_VALUE)
                {
                    D = minD;
                    X = xx;
                    Y = yy;
                }
            }
            for (int dx = 1; dx <= n; dx++)
            {
                int x1 = dx;
                int y1 = m;
                int xx = 0;
                int yy = 0;
                int minD = Integer.MAX_VALUE;
                for (int j = 0; j < p; j++)
                {
                    int d = Math.abs(x1 - x[j]) + Math.abs(y1 - y[j]);
                    if (d < minD)
                    {
                        minD = d;
                        xx = x1;
                        yy = y1;
                    }
                }
                if (D < minD && minD != 0 && minD != Integer.MAX_VALUE)
                {
                    D = minD;
                    X = xx;
                    Y = yy;
                }
            }
            for (int dy = 1; dy <= m; dy++)
            {
                int x1 = 1;
                int y1 = dy;
                int xx = 0;
                int yy = 0;
                int minD = Integer.MAX_VALUE;
                for (int j = 0; j < p; j++)
                {
                    int d = Math.abs(x1 - x[j]) + Math.abs(y1 - y[j]);
                    if (d < minD)
                    {
                        minD = d;
                        xx = x1;
                        yy = y1;
                    }
                }
                if (D < minD && minD != 0 && minD != Integer.MAX_VALUE)
                {
                    D = minD;
                    X = xx;
                    Y = yy;
                }
            }
            for (int dy = 1; dy <= m; dy++)
            {
                int x1 = n;
                int y1 = dy;
                int xx = 0;
                int yy = 0;
                int minD = Integer.MAX_VALUE;
                for (int j = 0; j < p; j++)
                {
                    int d = Math.abs(x1 - x[j]) + Math.abs(y1 - y[j]);
                    if (d < minD)
                    {
                        minD = d;
                        xx = x1;
                        yy = y1;
                    }
                }
                if (D < minD && minD != 0 && minD != Integer.MAX_VALUE)
                {
                    D = minD;
                    X = xx;
                    Y = yy;
                }
            }

            for (int i = 1; i <= Math.min(m, n); i++)
            {
                int x1 = i;
                int y1 = i;
                int xx = 0;
                int yy = 0;
                int minD = Integer.MAX_VALUE;
                for (int j = 0; j < p; j++)
                {
                    int d = Math.abs(x1 - x[j]) + Math.abs(y1 - y[j]);
                    if (d < minD)
                    {
                        minD = d;
                        xx = x1;
                        yy = y1;
                    }
                }
                if (D < minD && minD != 0 && minD != Integer.MAX_VALUE)
                {
                    D = minD;
                    X = xx;
                    Y = yy;
                }
            }
            for (int i = 1, ii = m; i <= n && ii >= 1; i++, ii--)
            {
                int x1 = i;
                int y1 = ii;
                int xx = 0;
                int yy = 0;
                int minD = Integer.MAX_VALUE;
                for (int j = 0; j < p; j++)
                {
                    int d = Math.abs(x1 - x[j]) + Math.abs(y1 - y[j]);
                    if (d < minD)
                    {
                        minD = d;
                        xx = x1;
                        yy = y1;
                    }
                }
                if (D < minD && minD != 0 && minD != Integer.MAX_VALUE)
                {
                    D = minD;
                    X = xx;
                    Y = yy;
                }
            }
            out.println(X + " " + Y);
        }

    }

    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.awt.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class C implements Runnable{

    // SOLUTION!!!
    // HACK ME PLEASE IF YOU CAN!!!
    // PLEASE!!!
    // PLEASE!!!
    // PLEASE!!!

    private final static Random rnd = new Random();
    private final static String fileName = "";

    private void solve() {
        int n = readInt();
        int m = readInt();

        int k = readInt();

        Point[] starts = readPointArray(k);
        for (Point start : starts) {
            start.x--;
            start.y--;
        }

        Point furthest = bfs(n, m, starts);
        out.println((furthest.x + 1) + " " + (furthest.y + 1));
    }

    private Point bfs(int n, int m, Point[] starts) {
        final int INF = n * m + 1;

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

        Queue<Integer> queue = new ArrayDeque<>();

        for (Point start : starts) {
            used[start.x][start.y] = true;
            queue.add(start.x * m + start.y);
        }

        int last = -1;
        while (queue.size() > 0) {
            int from = queue.poll();
            last = from;

            int fromX = from / m, fromY = from % m;

            for (int[] step : steps) {
                int toX = fromX + step[0];
                int toY = fromY + step[1];

                if (!checkCell(toX, n, toY, m)) continue;
                if (used[toX][toY]) continue;

                used[toX][toY] = true;
                queue.add(toX * m + toY);
            }
        }

        return new Point(last / m, last % m);
    }

    /////////////////////////////////////////////////////////////////////

    private final static boolean FIRST_INPUT_STRING = false;
    private final static boolean MULTIPLE_TESTS = true;
    private final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private final static int MAX_STACK_SIZE = 128;

    private final static boolean OPTIMIZE_READ_NUMBERS = false;

    /////////////////////////////////////////////////////////////////////

    public void run(){
        try{
            timeInit();
            Locale.setDefault(Locale.US);

            init();

            if (ONLINE_JUDGE) {
                solve();
            } else {
                do {
                    try {
                        timeInit();
                        solve();
                        time();

                        out.println();
                    } catch (NumberFormatException e) {
                        break;
                    } catch (NullPointerException e) {
                        if (FIRST_INPUT_STRING) break;
                        else throw e;
                    }
                } while (MULTIPLE_TESTS);
            }

            out.close();
            time();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    /////////////////////////////////////////////////////////////////////

    private BufferedReader in;
    private OutputWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args){
        new Thread(null, new C(), "", MAX_STACK_SIZE * (1L << 20)).start();
    }

    /////////////////////////////////////////////////////////////////////

    private void init() throws FileNotFoundException{
        Locale.setDefault(Locale.US);

        in = new BufferedReader(new FileReader("input.txt"));
        out = new OutputWriter("output.txt");
    }

    ////////////////////////////////////////////////////////////////

    private long timeBegin;

    private void timeInit() {
        this.timeBegin = System.currentTimeMillis();
    }

    private void time(){
        long timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    private void debug(Object... objects){
        if (ONLINE_JUDGE){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    /////////////////////////////////////////////////////////////////////

    private String delim = " ";

    private String readLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeIOException(e);
        }
    }

    private String readString() {
        try {
            while(!tok.hasMoreTokens()){
                tok = new StringTokenizer(readLine());
            }

            return tok.nextToken(delim);
        } catch (NullPointerException e) {
            return null;
        }
    }

    /////////////////////////////////////////////////////////////////

    private final char NOT_A_SYMBOL = '\0';

    private char readChar() {
        try {
            int intValue = in.read();

            if (intValue == -1){
                return NOT_A_SYMBOL;
            }

            return (char) intValue;
        } catch (IOException e) {
            throw new RuntimeIOException(e);
        }
    }

    private char[] readCharArray() {
        return readLine().toCharArray();
    }

    private char[][] readCharField(int rowsCount) {
        char[][] field = new char[rowsCount][];
        for (int row = 0; row < rowsCount; ++row) {
            field[row] = readCharArray();
        }

        return field;
    }

    /////////////////////////////////////////////////////////////////

    private long optimizedReadLong() {
        int sign = 1;
        long result = 0;
        boolean started = false;
        while (true) {
            try {
                int j = in.read();
                if (-1 == j) {
                    if (started) return sign * result;
                    throw new NumberFormatException();
                }

                if (j == '-') {
                    if (started) throw new NumberFormatException();
                    sign = -sign;
                }

                if ('0' <= j && j <= '9') {
                    result = result * 10 + j - '0';
                    started = true;
                } else if (started) {
                    return sign * result;
                }
            } catch (IOException e) {
                throw new RuntimeIOException(e);
            }
        }
    }

    private int readInt() {

        if (!OPTIMIZE_READ_NUMBERS) {
            return Integer.parseInt(readString());
        } else {
            return (int) optimizedReadLong();
        }
    }

    private int[] readIntArray(int size) {
        int[] array = new int[size];

        for (int index = 0; index < size; ++index){
            array[index] = readInt();
        }

        return array;
    }

    private int[] readSortedIntArray(int size) {
        Integer[] array = new Integer[size];

        for (int index = 0; index < size; ++index) {
            array[index] = readInt();
        }
        Arrays.sort(array);

        int[] sortedArray = new int[size];
        for (int index = 0; index < size; ++index) {
            sortedArray[index] = array[index];
        }

        return sortedArray;
    }

    private int[] readIntArrayWithDecrease(int size) {
        int[] array = readIntArray(size);

        for (int i = 0; i < size; ++i) {
            array[i]--;
        }

        return array;
    }

    ///////////////////////////////////////////////////////////////////

    private int[][] readIntMatrix(int rowsCount, int columnsCount) {
        int[][] matrix = new int[rowsCount][];

        for (int rowIndex = 0; rowIndex < rowsCount; ++rowIndex) {
            matrix[rowIndex] = readIntArray(columnsCount);
        }

        return matrix;
    }

    private int[][] readIntMatrixWithDecrease(int rowsCount, int columnsCount) {
        int[][] matrix = new int[rowsCount][];

        for (int rowIndex = 0; rowIndex < rowsCount; ++rowIndex) {
            matrix[rowIndex] = readIntArrayWithDecrease(columnsCount);
        }

        return matrix;
    }

    ///////////////////////////////////////////////////////////////////

    private long readLong() {
        if (!OPTIMIZE_READ_NUMBERS) {
            return Long.parseLong(readString());
        } else {
            return optimizedReadLong();
        }
    }

    private long[] readLongArray(int size) {
        long[] array = new long[size];

        for (int index = 0; index < size; ++index){
            array[index] = readLong();
        }

        return array;
    }

    ////////////////////////////////////////////////////////////////////

    private double readDouble() {
        return Double.parseDouble(readString());
    }

    private double[] readDoubleArray(int size) {
        double[] array = new double[size];

        for (int index = 0; index < size; ++index){
            array[index] = readDouble();
        }

        return array;
    }

    ////////////////////////////////////////////////////////////////////

    private BigInteger readBigInteger() {
        return new BigInteger(readString());
    }

    private BigDecimal readBigDecimal() {
        return new BigDecimal(readString());
    }

    /////////////////////////////////////////////////////////////////////

    private Point readPoint() {
        int x = readInt();
        int y = readInt();
        return new Point(x, y);
    }

    private Point[] readPointArray(int size) {
        Point[] array = new Point[size];

        for (int index = 0; index < size; ++index){
            array[index] = readPoint();
        }

        return array;
    }

    /////////////////////////////////////////////////////////////////////

    @Deprecated
    private List<Integer>[] readGraph(int vertexNumber, int edgeNumber) {
        @SuppressWarnings("unchecked")
        List<Integer>[] graph = new List[vertexNumber];

        for (int index = 0; index < vertexNumber; ++index){
            graph[index] = new ArrayList<>();
        }

        while (edgeNumber-- > 0){
            int from = readInt() - 1;
            int to = readInt() - 1;

            graph[from].add(to);
            graph[to].add(from);
        }

        return graph;
    }

    private static class GraphBuilder {

        final int size;
        final List<Integer>[] edges;

        static GraphBuilder createInstance(int size) {
            List<Integer>[] edges = new List[size];
            for (int v = 0; v < size; ++v) {
                edges[v] = new ArrayList<>();
            }

            return new GraphBuilder(edges);
        }

        private GraphBuilder(List<Integer>[] edges) {
            this.size = edges.length;
            this.edges = edges;
        }

        public void addEdge(int from, int to) {
            addDirectedEdge(from, to);
            addDirectedEdge(to, from);
        }

        public void addDirectedEdge(int from, int to) {
            edges[from].add(to);
        }

        public int[][] build() {
            int[][] graph = new int[size][];
            for (int v = 0; v < size; ++v) {
                List<Integer> vEdges = edges[v];
                graph[v] = castInt(vEdges);
            }

            return graph;
        }
    }

    /////////////////////////////////////////////////////////////////////

    private static class IntIndexPair {

        static Comparator<IntIndexPair> increaseComparator = new Comparator<C.IntIndexPair>() {

            @Override
            public int compare(C.IntIndexPair indexPair1, C.IntIndexPair indexPair2) {
                int value1 = indexPair1.value;
                int value2 = indexPair2.value;

                if (value1 != value2) return value1 - value2;

                int index1 = indexPair1.index;
                int index2 = indexPair2.index;

                return index1 - index2;
            }
        };

        static Comparator<IntIndexPair> decreaseComparator = new Comparator<C.IntIndexPair>() {

            @Override
            public int compare(C.IntIndexPair indexPair1, C.IntIndexPair indexPair2) {
                int value1 = indexPair1.value;
                int value2 = indexPair2.value;

                if (value1 != value2) return -(value1 - value2);

                int index1 = indexPair1.index;
                int index2 = indexPair2.index;

                return index1 - index2;
            }
        };

        static IntIndexPair[] from(int[] array) {
            IntIndexPair[] iip = new IntIndexPair[array.length];
            for (int i = 0; i < array.length; ++i) {
                iip[i] = new IntIndexPair(array[i], i);
            }

            return iip;
        }

        int value, index;

        IntIndexPair(int value, int index) {
            super();
            this.value = value;
            this.index = index;
        }

        int getRealIndex() {
            return index + 1;
        }
    }

    private IntIndexPair[] readIntIndexArray(int size) {
        IntIndexPair[] array = new IntIndexPair[size];

        for (int index = 0; index < size; ++index) {
            array[index] = new IntIndexPair(readInt(), index);
        }

        return array;
    }

    /////////////////////////////////////////////////////////////////////

    private static class OutputWriter extends PrintWriter {

        final int DEFAULT_PRECISION = 12;

        private int precision;
        private String format, formatWithSpace;

        {
            precision = DEFAULT_PRECISION;

            format = createFormat(precision);
            formatWithSpace = format + " ";
        }

        OutputWriter(OutputStream out) {
            super(out);
        }

        OutputWriter(String fileName) throws FileNotFoundException {
            super(fileName);
        }

        int getPrecision() {
            return precision;
        }

        void setPrecision(int precision) {
            precision = max(0, precision);
            this.precision = precision;

            format = createFormat(precision);
            formatWithSpace = format + " ";
        }

        String createFormat(int precision){
            return "%." + precision + "f";
        }

        @Override
        public void print(double d){
            printf(format, d);
        }

        void printWithSpace(double d){
            printf(formatWithSpace, d);
        }

        void printAll(double...d){
            for (int i = 0; i < d.length - 1; ++i){
                printWithSpace(d[i]);
            }

            print(d[d.length - 1]);
        }

        @Override
        public void println(double d){
            printlnAll(d);
        }

        void printlnAll(double... d){
            printAll(d);
            println();
        }
    }

    /////////////////////////////////////////////////////////////////////

    private static class RuntimeIOException extends RuntimeException {

        /**
         *
         */
        private static final long serialVersionUID = -6463830523020118289L;

        RuntimeIOException(Throwable cause) {
            super(cause);
        }
    }

    /////////////////////////////////////////////////////////////////////
    //////////////// Some useful constants and functions ////////////////
    /////////////////////////////////////////////////////////////////////

    private static final int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    private static final int[][] steps8 = {
            {-1, 0}, {1, 0}, {0, -1}, {0, 1},
            {-1, -1}, {1, 1}, {1, -1}, {-1, 1}
    };

    private static boolean checkCell(int row, int rowsCount, int column, int columnsCount) {
        return checkIndex(row, rowsCount) && checkIndex(column, columnsCount);
    }

    private static boolean checkIndex(int index, int lim){
        return (0 <= index && index < lim);
    }

    /////////////////////////////////////////////////////////////////////

    private static boolean checkBit(int mask, int bit){
        return (mask & (1 << bit)) != 0;
    }
    private static boolean checkBit(long mask, int bit){
        return (mask & (1L << bit)) != 0;
    }

    /////////////////////////////////////////////////////////////////////

    private static long getSum(int[] array) {
        long sum = 0;
        for (int value: array) {
            sum += value;
        }

        return sum;
    }

    private static Point getMinMax(int[] array) {
        int min = array[0];
        int max = array[0];

        for (int index = 0, size = array.length; index < size; ++index, ++index) {
            int value = array[index];

            if (index == size - 1) {
                min = min(min, value);
                max = max(max, value);
            } else {
                int otherValue = array[index + 1];

                if (value <= otherValue) {
                    min = min(min, value);
                    max = max(max, otherValue);
                } else {
                    min = min(min, otherValue);
                    max = max(max, value);
                }
            }
        }

        return new Point(min, max);
    }

    /////////////////////////////////////////////////////////////////////

    private static int[] getPrimes(int n) {
        boolean[] used = new boolean[n];
        used[0] = used[1] = true;

        int size = 0;
        for (int i = 2; i < n; ++i) {
            if (!used[i]) {
                ++size;
                for (int j = 2 * i; j < n; j += i) {
                    used[j] = true;
                }
            }
        }

        int[] primes = new int[size];
        for (int i = 0, cur = 0; i < n; ++i) {
            if (!used[i]) {
                primes[cur++] = i;
            }
        }

        return primes;
    }

    /////////////////////////////////////////////////////////////////////

    private static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    private static long gcd(long a, long b) {
        return (a == 0 ? b : gcd(b % a, a));
    }

    /////////////////////////////////////////////////////////////////////

    private static class MultiSet<ValueType> {

        public static <ValueType> MultiSet<ValueType> createMultiSet() {
            Map<ValueType, Integer> multiset = new HashMap<>();
            return new MultiSet<>(multiset);
        }

        private final Map<ValueType, Integer> multiset;
        private int size;

        public MultiSet(Map<ValueType, Integer> multiset) {
            this.multiset = multiset;
            this.size = 0;
        }

        public int size() {
            return size;
        }

        public void inc(ValueType value) {
            int count = get(value);
            multiset.put(value, count + 1);

            ++size;
        }

        public void dec(ValueType value) {
            int count = get(value);
            if (count == 0) return;

            if (count == 1) multiset.remove(value);
            else multiset.put(value, count - 1);

            --size;
        }

        public int get(ValueType value) {
            Integer count = multiset.get(value);
            return (count == null ? 0 : count);
        }
    }

    /////////////////////////////////////////////////////////////////////

    private static class IdMap<KeyType> extends HashMap<KeyType, Integer> {

        /**
         *
         */
        private static final long serialVersionUID = -3793737771950984481L;

        public IdMap() {
            super();
        }

        int getId(KeyType key) {
            Integer id = super.get(key);
            if (id == null) {
                super.put(key, id = size());
            }

            return id;
        }
    }

    /////////////////////////////////////////////////////////////////////

    private static int[] castInt(List<Integer> list) {
        int[] array = new int[list.size()];
        for (int i = 0; i < array.length; ++i) {
            array[i] = list.get(i);
        }

        return array;
    }

    private static long[] castLong(List<Long> list) {
        long[] array = new long[list.size()];
        for (int i = 0; i < array.length; ++i) {
            array[i] = list.get(i);
        }

        return array;
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import java.util.*;

public class A_GENERAL {

	// for fast output printing  : use printwriter or stringbuilder
	// remember to close pw using pw.close()
	static StringBuilder sb = new StringBuilder();
	static long seive_size = (long) 1e6;
	static String alpha = "abcdefghijklmnopqrstuvwxyz";
    static ArrayList<Integer> primes = new ArrayList<>();
    static boolean[] seive_set = new boolean[(int) seive_size+1];
    static int n, m, k;
    static ArrayList<Integer>[] adj;
    static boolean[] vis;
    static ArrayDeque<Integer> q = new ArrayDeque<>();
    static final long MOD = 998244353;
    static int[] dx = new int[] {1, 0, -1, 0, 1, -1, 1, -1};
    static int[] dy = new int[] {0, 1, 0, -1, -1, 1, 1, -1};
    static long[][] arr;
    static int[] rank;
    static int[] parent;

    static int[] s;
    static long[] a;
    public static void main(String[] args) throws FileNotFoundException {
//		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
//		MyScanner sc = new MyScanner();
		Scanner sc = new Scanner(new File("input.txt"));
		PrintWriter out = new PrintWriter("output.txt");
		n = sc.nextInt();
		m = sc.nextInt();
		k = sc.nextInt();
		ArrayDeque<iPair> qq = new ArrayDeque<>();
		boolean[][] vis = new boolean[n+1][m+1];
		for(int i = 0; i < k; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			qq.add(new iPair(u, v));
			vis[u][v] = true;
		}
		iPair last = null;
		while(!qq.isEmpty()) {
			iPair pp = qq.poll();
			int i = pp.f;
			int j = pp.s;
			if(isValid(i-1, j) && !vis[i-1][j]) {
				qq.add(new iPair(i-1, j));
				vis[i-1][j] = true;
			}
			if(isValid(i+1, j) && !vis[i+1][j]) {
				qq.add(new iPair(i+1, j));
				vis[i+1][j] = true;
			}
			if(isValid(i,  j-1) && !vis[i][j-1]) {
				qq.add(new iPair(i, j-1));
				vis[i][j-1] = true;
			}
			if(isValid(i, j+1) && !vis[i][j+1]) {
				qq.add(new iPair(i, j+1));
				vis[i][j+1] = true;
			}
			last = pp;
		}
		out.println(last.f + " " + last.s);
		sc.close();
		out.close();
	}
    public static boolean isValid(int i, int j) {
    	if(i < 1 || i > n || j < 1 || j > m) return false;
    	return true;
    }
    public static class Triplet implements Comparable<Triplet> {
		int x;
    	int y;
    	int z;
    	Triplet(int x, int y, int z) {
    		this.x = x;
    		this.y = y;
    		this.z = z;
    	}
    	public int compareTo(Triplet o) {
    		return Integer.compare(this.x, o.x);
    	}
    }
    public static class iPair implements Comparable<iPair>  {
    	int f;
    	int s;
    	iPair(int f, int s) {
    		this.f = f;
    		this.s = s;
    	}
    	public int compareTo(iPair o) {
    		return Integer.compare(this.f,  o.f);
    	}
    }

	public static class Pair implements Comparable<Pair>{
		long f;
		long s;
		Pair(long f, long s) {
			this.f = f;
			this.s = s;
		}
		public int compareTo(Pair o) {
			return Long.compare(this.f, o.f);
		}
	}
	public static void init(int n) {
    	adj = new ArrayList[n+1];
    	vis = new boolean[n+1];
    	parent = new int[n+1];
		rank = new int[n+1];
    	for(int i = 0; i <= n; i++) {
    		adj[i] = new ArrayList<>();
    		parent[i] = i;
			rank[i] = 0;
    	}
    }
	// print string "s" multiple times
	// prefer to use this function for multiple printing
	public static String mp(String s, int times) {
		return String.valueOf(new char[times]).replace("\0", s);
	}
	// take log with base 2
 	public static long log2(long k) {
 		return 63-Long.numberOfLeadingZeros(k);
 	}

 	// using lambda function for sorting
   	public static void lambdaSort() {
   		Arrays.sort(arr, (a, b) -> Double.compare(a[0], b[0]));
   	}

  	// (n choose k) = (n/k) * ((n-1) choose (k-1))
  	public static long choose(long n, long k) {
 		return (k == 0) ? 1 : (n*choose(n-1, k-1))/k;
 	}

 	// just for keeping gcd function for other personal purposes
 	public static long gcd(long a, long b) {
 		return (a == 0) ? b : gcd(b%a, a);
 	}

	public static long max(long... as) {
        long max = Long.MIN_VALUE;
        for (long a : as) max = Math.max(a, max);
        return max;
    }

    public static long min(int... as) {
        long min = Long.MAX_VALUE;
        for (long a : as) min = Math.min(a, min);
        return min;
    }

    public static long modpow(long x, long n, long mod) {
    	if(n == 0) return 1%mod;
    	long u = modpow(x, n/2, mod);
    	u = (u*u)%mod;
    	if(n%2 == 1) u = (u*x)%mod;
    	return u;
    }
 	// ======================= binary search (lower and upper bound) =======================
	public static int lowerBound(long[] a, int x) {
		int lo = 0;
 		int hi = a.length-1;
 		int ans = -1;
 		while(lo <= hi) {
 			int mid = (lo+hi)/2;
 			if(x < a[mid]) {
 				hi = mid-1;
 			} else if(x > a[mid]) {
 				lo = mid+1;
 			} else if(lo != hi) {
 				 hi = mid-1; 		// for first occurrence
 				 ans = mid;
 			} else {
 				return mid;
 			}
 		}
 		return ans;
	}

	public static int upperBound(long[] a, long x) {
		int lo = 0;
		int hi = a.length-1;
		int ans = -1;
		while(lo <= hi) {
			int mid = (lo+hi)/2;
			if(x < a[mid]) {
				hi = mid-1;
			} else if(x > a[mid]) {
				lo = mid+1;
			} else if(lo != hi) {
				lo = mid+1;			// for last occurrence
				ans = mid;
			} else {
				return mid;
			}
		}
		return ans;
	}
	// ================================================================

	// ================== SEIVE OF ERATOSTHENES =======================
	// Complexity : O(N * log(log(N)))       ( almost O(N) )
	public static void generatePrimes() {
		// set.add(0);
		// set.add(1);
		Arrays.fill(seive_set, true);
		seive_set[0] = false;
		seive_set[1] = false;
		for(int i = 2; i <= seive_size; i++) {
			if(seive_set[i]) {
				for(long j = (long) i*i; j <= seive_size; j+=i)
					seive_set[(int)j] = false;
				primes.add(i);
			}
		}
	}

	public static boolean isPrime(long N) {
		if(N <= seive_size) return seive_set[(int)N];
		for (int i = 0; i < (int)primes.size(); i++)
			if (N % primes.get(i) == 0) return false;
		return true;
	}
	// ===========================================================

 	// ================ Permutation of String ====================
 	public static void permute(String str) {
 		permute(str, 0, str.length()-1);
 	}
 	public static void permute(String str, int l, int r)
    {
        if (l == r)
            System.out.println(str);
        else
        {
            for (int i = l; i <= r; i++)
            {
                str = swap(str,l,i);
                permute(str, l+1, r);
                str = swap(str,l,i);
            }
        }
    }
	public static String swap(String a, int i, int j)
    {
        char temp;
        char[] charArray = a.toCharArray();
        temp = charArray[i] ;
        charArray[i] = charArray[j];
        charArray[j] = temp;
        return String.valueOf(charArray);
    }
	// Union-find
	// static int[] parent, rank;
//	public static void makeSet(int n) {
//
//		parent = new int[n+1];
//		rank = new int[n+1];
//		for(int i = 1; i <= n; i++) {
//			parent[i] = i;
//			rank[i] = 0;
//		}
//	}
	public static int find(int u) {

		if(parent[u] == u)	return u;

		int v = find(parent[u]);
		parent[u] = v;
		return v;

	}
	public static boolean connected(int u, int v) {
		return find(u) == find(v);
	}
	public static void Union(int u, int v) {

		int x = find(u);				//root of u
		int y = find(v);				//root of v

		if(x == y)		return;
		if(rank[x] == rank[y]) {
			parent[y] = x;
			rank[x]++;
		}
		else if(rank[x] > rank[y]) {
			parent[y] = x;
		}
		else {
			parent[x] = y;
		}

	}

//	public static int dijkstra(int x, int y) {
//    	int[] dist = new int[n+1];
//    	Arrays.fill(dist, Integer.MAX_VALUE);
//    	PriorityQueue<Node> q = new PriorityQueue<>();
//    	q.add(new Node(x, 0));
//    	dist[x] = 0;
//    	while(!q.isEmpty()) {
//    		Node node = q.poll();
//    		int u = node.key;
//    		if(u == y) {
//    			break;
//    		}
//    		for(int v : res[u]) {
//    			if(dist[v] > dist[u]+count[u]) {
//    				dist[v] = dist[u] + count[u];
//    				q.add(new Node(v, dist[v]));
//    			}
//    		}
//    	}
//    	if(dist[y] == Integer.MAX_VALUE) {
//    		return -1;
//    	}
//    	return dist[y];
//    }

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			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;}
		int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
	}

}


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

public class A {

	static int dx[] = { 1, -1, 0, 0 };
	static int dy[] = { 0, 0, 1, -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();
		int[][] grid = new int[n][m];
		for (int[] i : grid)
			Arrays.fill(i, -1);
		Queue<Pair> q = new LinkedList<>();
		int k = sc.nextInt();
		for (int i = 0; i < k; i++) {
			int x = sc.nextInt() - 1, y = sc.nextInt() - 1;
			grid[x][y] = 0;
			q.add(new Pair(x, y));
		}
		Pair p = new Pair(-1, -1);
		while (!q.isEmpty()) {
			p = q.poll();
			for (int i = 0; i < dx.length; i++) {
				int tx = p.x + dx[i], ty = p.y + dy[i];
				if (tx >= 0 && tx < n && ty >= 0 && ty < m && grid[tx][ty] == -1) {
					grid[tx][ty] = grid[p.x][p.y] + 1;
					q.add(new Pair(tx, ty));
				}
			}
		}
		out.println(p);
		out.flush();
		out.close();
	}

	static class Pair {
		int x, y;

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

		public String toString() {
			return x + 1 + " " + (y + 1);
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

		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 boolean ready() throws IOException {
			return br.ready();
		}
	}
}


import java.io.*;
import java.util.List;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Problem {

	public static Pair solve(Forest f, List<Pair> queue){
		Pair current = null, next = null;
		int index = 0;
		while(queue.size() > 0){
			current = queue.remove(0);
			index = f.desk[current.x][current.y];
				if(current.x>0){
					next = new Pair(current.x-1,current.y);
					if(f.desk[next.x][next.y]==0){
						f.desk[next.x][next.y] = index+1;
						queue.add(next);
					}
				}
				if(current.x<f.N-1){
					next = new Pair(current.x+1,current.y);
					if(f.desk[next.x][next.y]==0){
						f.desk[next.x][next.y] = index+1;
						queue.add(next);
					}
				}
				if(current.y>0){
					next = new Pair(current.x,current.y-1);
					if(f.desk[next.x][next.y]==0){
						f.desk[next.x][next.y] = index+1;
						queue.add(next);
					}
				}
				if(current.y<f.M-1){
					next = new Pair(current.x,current.y+1);
					if(f.desk[next.x][next.y]==0){
						f.desk[next.x][next.y] = index+1;
						queue.add(next);
					}
				}
		}
		return f.findMax();
	}

	public static void main(String[] args){
		String buffer = null;
		StringTokenizer st = null;
		Forest f = null;
		List<Pair> pairs = new LinkedList<Pair>();
		Integer N,M,K,x,y;
		try {
			BufferedReader in = new BufferedReader(
							new FileReader("input.txt")
							);
			FileWriter out = new FileWriter("output.txt");
			buffer = in.readLine();
			st = new StringTokenizer(buffer);
			N = new Integer(st.nextToken());
			M = new Integer(st.nextToken());
			f = new Forest(N,M);
			buffer = in.readLine();
			st = new StringTokenizer(buffer);
			K = new Integer(st.nextToken());
			buffer = in.readLine();
			st = new StringTokenizer(buffer);
			for(int i = 0; i<K; i++){
				x = new Integer(st.nextToken());
				y = new Integer(st.nextToken());
				f.desk[x-1][y-1] = 1;
				pairs.add(new Pair(x-1,y-1));
			}
			Pair res = solve(f,pairs);

			out.write(res.toString());
			out.flush();
		} catch (Exception e) {
		}
	}
}

class Pair {
	public Pair(int i, int j){
		x = i;
		y = j;
	}
	public String toString(){
		return (x+1) + " " + (y+1);
	}
	public int x;
	public int y;
}

class Forest {
	public Forest(int n, int m){
		N = n;
		M = m;
		desk = new int[N][M];
	}

	public Pair findMax(){
		Pair max = new Pair(0,0);
		for(int i = 0; i<N; i++){
			for(int j = 0; j<M; j++){
				if(desk[i][j]>desk[max.x][max.y]){
					max.x = i;
					max.y = j;
				}
			}
		}
		return max;
	}

	public int N;
	public int M;
	public int[][] desk;
}


import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class FireAgain {

	Scanner in;
	PrintWriter out;

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		new FireAgain().run();

	}

	void run() throws IOException {
		in = new Scanner(new FileReader("input.txt"));
        out = new PrintWriter(new FileWriter("output.txt"));

		solve();

		in.close();
		out.close();
	}

	private void solve() {
		// TODO Auto-generated method stub
		int N = in.nextInt();
		int M = in.nextInt();
		int[][] burn = new int[N + 1][M + 1];
		int K = in.nextInt();

		int[] qx = new int[N * M];
		int[] qy = new int[N * M];

		int first = 0;
		int last = 0;
		for (int i = 0; i < K; i ++){
			qx[last] = in.nextInt();
			qy[last] = in.nextInt();
			burn[qx[last]][qy[last]] = 1;
			last ++;
		}

		while (first < last){
			int x = qx[first];
			int y = qy[first];
			if (x - 1 > 0 && burn[x - 1][y] == 0){
				burn[x - 1][y] = 1;
				qx[last] = x - 1;
				qy[last] = y;
				last ++;
			}
			if (y - 1 > 0 && burn[x][y - 1] == 0){
				burn[x][y - 1] = 1;
				qx[last] = x;
				qy[last] = y - 1;
				last ++;
			}
			if (x + 1 <= N && burn[x + 1][y] == 0){
				burn[x + 1][y] = 1;
				qx[last] = x + 1;
				qy[last] = y;
				last ++;
			}
			if (y + 1 <= M && burn[x][y + 1] == 0){
				burn[x][y + 1] = 1;
				qx[last] = x;
				qy[last] = y + 1;
				last ++;
			}
			first ++;
		}

		out.println(qx[last - 1] + " " + qy[last - 1]);
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class FireAgain {
	static int n;
	static int m;

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader r = new BufferedReader(new FileReader("input.txt"));
		String s = r.readLine();
		String[] sp = s.split(" ");
		n = new Integer(sp[0]);
		m = new Integer(sp[1]);
		boolean[][] v = new boolean[n][m];
		r.readLine();
		s = r.readLine();
		sp = s.split(" ");
		Queue<Integer> q = new LinkedList<Integer>();
		for (int i = 0; i < sp.length; i += 2) {
			v[new Integer(sp[i]) - 1][new Integer(sp[i + 1]) - 1] = true;
			q.add(new Integer(sp[i]) - 1);
			q.add(new Integer(sp[i + 1]) - 1);
		}

		int[] dx = { 1, -1, 0, 0 };
		int[] dy = { 0, 0, 1, -1 };
		int lx = -1;
		int ly = -1;
		while (!q.isEmpty()) {
			int x = q.remove();
			int y = q.remove();
			lx = x;
			ly = y;
			for (int i = 0; i < dy.length; i++) {
				int nx = x + dx[i];
				int ny = y + dy[i];
				if (valid(nx, ny) && !v[nx][ny]) {
					v[nx][ny] = true;
					q.add(nx);
					q.add(ny);
				}
			}
		}
		lx++;
		ly++;
		BufferedWriter wr=new BufferedWriter(new FileWriter("output.txt"));
		wr.write(""+lx + " " + ly);
		wr.newLine();
		wr.close();

	}

	private static boolean valid(int nx, int ny) {
		return nx >= 0 && nx < n && ny >= 0 && ny < m;
	}
}


import static java.lang.Math.*;
import java.io.*;
import java.math.*;
import java.util.*;

public class Solution implements Runnable {

	public static void main(String... strings) throws InterruptedException {
		new Thread(new Solution()).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String next() throws Exception {
		if (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

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

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

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

	@Override
	public void run() {
		try {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter(new FileWriter("output.txt"));
			solve();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			out.close();
		}
	}
	int n, m, k, xor = 0;
	boolean[][] used;
	HashSet<Long> [] set;
	void solve() throws Exception {
		n = nextInt();
		m = nextInt();
		k = nextInt();
		used = new boolean[n][m];
		set = new HashSet[2];
		for(int i = 0; i < 2; set[i++] = new HashSet<Long>());

		for(int i = 0; i < k; i++){
			int x = nextInt()-1, y = nextInt()-1;
			used[x][y] = true;
			set[0].add(10000L*x + y);
		}
		for (;;xor ^= 1){
			set[xor^1].clear();
			int ansx = -1, ansy = -1;
			for (long i : set[xor]){
				int x = (int)(i/10000), y = (int)(i%10000);
				if (ansx < 0){
					ansx = x+1;
					ansy = y+1;
				}
				add(x+1, y);
				add(x-1, y);
				add(x, y+1);
				add(x, y-1);
			}
			if (set[xor^1].size() == 0){
				out.println(ansx + " " + ansy);
				break;
			}
		}
	}
	public void add(int x, int y){
		if (!( x >= 0 && y >= 0 && x < n && y < m && !used[x][y])) return;
		set[xor^1].add(10000L*x + y);
		used[x][y] = true;
	}

}


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

public class Main {

    static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer st;

    static int[][] moves = new int[][]{{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

    static boolean correct(int x, int y, int n, int m) {
        return (x >= 0 && x < n && y >= 0 && y < m);
    }

    static void solve() throws Exception {
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        int[][] order = new int[n][m];
        boolean[][] used = new boolean[n][m];
        Queue<Integer[]> q = new LinkedList<>();
        Set<String> set = new HashSet<String>();
        for(int i = 0; i < k; i++) {
            int x = nextInt() - 1;
            int y = nextInt() - 1;
            order[x][y] = 1;
            used[x][y] = true;
            q.add(new Integer[] {x, y});
            set.add(x + "" + y);
        }
        while(!q.isEmpty()) {
            Integer[] v = q.remove();
            for(int[] move : moves) {
                int x = v[0] + move[0];
                int y = v[1] + move[1];
//              if(set.contains(x + "" + y)) {
//                  continue;
//              }
                if(correct(x, y, n, m) && !used[x][y]) {
                    q.add(new Integer[] {x, y});
                    used[x][y] = true;
                    order[x][y] = order[v[0]][v[1]] + 1;
                }
            }
        }
        int max = Integer.MIN_VALUE;
        int maxI = -1;
        int maxJ = -1;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if(order[i][j] > max) {
                    max = order[i][j];
                    maxI = i;
                    maxJ = j;
                }
            }
        }
        maxI++;
        maxJ++;
        out.println(maxI + " " + maxJ);
    }

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

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

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

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

    public static void main(String[] args) {
        try {
            InputStream input = System.in;
            OutputStream output = System.out;
            br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
            out = new PrintWriter(new PrintStream(new File("output.txt")));
            solve();
            out.close();
            br.close();
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main1 {

	static int dr[] = { 0, 0, 1, -1 };
	static int dc[] = { 1, -1, 0, 0 };

	static boolean isValid(int r, int c) {
		if (r >= n || r < 0 || c >= m || c < 0)
			return false;

		return true;
	}

	static int grid[][];
	static int n, m;

	public static void main(String[] args) throws IOException {
		FastReader input = new FastReader();
		PrintWriter out = new PrintWriter("output.txt");

		n = input.nextInt();
		m = input.nextInt();
		grid = new int[n][m];

		int k = input.nextInt();

		for (int i = 0; i < n; i++) {
			Arrays.fill(grid[i], Integer.MAX_VALUE);
		}

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

		for (int i = 0; i < k; i++) {
			int x = input.nextInt() - 1;
			int y = input.nextInt() - 1;

			q.add(new Pair(x, y));
			grid[x][y] = 0;

			while (!q.isEmpty()) {
				Pair cur = q.poll();
				for (int j = 0; j < dr.length; j++) {
					int r = cur.x;
					int c = cur.y;
					int nr = r + dr[j];
					int nc = c + dc[j];
					int dist = grid[r][c] + 1;

					if (isValid(nr, nc) && grid[nr][nc] > dist) {
						grid[nr][nc] = dist;

						q.add(new Pair(nr, nc));
					}

				}
			}
		}

		int max = -1;
		int x = -1;
		int y = -1;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (grid[i][j] > max) {
					max = grid[i][j];
					x = i + 1;
					y = j + 1;
				}
			}
		}
		out.println(x + " " + y);
		out.flush();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File("input.txt")));
		}

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

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

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

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

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}

	static class con {
		static int IINF = (int) 1e9;
		static int _IINF = (int) -1e9;
		static long LINF = (long) 1e15;
		static long _LINF = (long) -1e15;
		static double EPS = 1e-9;
	}

	static class Triple implements Comparable<Triple> {
		int x;
		int y;
		int z;

		Triple(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		@Override
		public int compareTo(Triple o) {
			if (x == o.x && y == o.y)
				return z - o.z;
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}
	}

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

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

		}

		@Override
		public int compareTo(Pair o) {
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}

		@Override
		public String toString() {

			return "(" + x + ", " + y + ")";
		}

	}

	static void shuffle(int[] a) {
		for (int i = 0; i < a.length; i++) {
			int r = i + (int) (Math.random() * (a.length - i));
			int tmp = a[r];
			a[r] = a[i];
			a[i] = tmp;
		}
	}

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	public static int n,m;
	public static void main(String[] arg) {
		FastScanner scan = null;
		PrintWriter out = null;
		try{
			scan = new FastScanner(new FileInputStream("input.txt"));
			out = new PrintWriter(new FileOutputStream("output.txt"));
		}catch(FileNotFoundException e){
			scan = new FastScanner(System.in);
			out = new PrintWriter(System.out);
		}

		 n = scan.nextInt();
		 m = scan.nextInt();
		int k = scan.nextInt();
		int[][] board = new int[n+1][m+1];
		String[] ins = scan.nextLine().split(" ",-1);
		List<Integer> ps = new ArrayList<Integer>();
		for(int i = 0; i < 2 * k; i += 2){
			int a = Integer.parseInt(ins[i]);
			int b = Integer.parseInt(ins[i+1]);
			board[a][b] = 1;
			ps.add(a * 2001 + b);
		}

		int retx = 1, rety = 1;
		int[] dx = {0,1,0,-1};
		int[] dy = {1,0,-1,0};
		while(true){
			boolean find = false;
			List<Integer> ps2 = new ArrayList<Integer>();
			for(Integer p : ps){
				int i = p / 2001;
				int j = p % 2001;
				for(int q = 0; q < 4; q++){
					int nx = i + dx[q];
					int ny = j + dy[q];
					if(in(nx,ny) && board[nx][ny] == 0){
						board[nx][ny] = 1;
						retx = nx;
						rety = ny;
						find = true;
						ps2.add(nx * 2001 + ny);
					}
				}
				board[i][j] = 2;
			}
			ps = ps2;
			if(!find) break;
		}
		out.println(retx + " " + rety);
		out.close();
	}
	public static boolean in(int i, int j){
		return (1 <= i && i <= n) && (1 <= j && j <= m);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream is) {
			try {
				br = new BufferedReader(new InputStreamReader(is));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

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

		String nextLine() {
	        try {
	            return br.readLine();
	        }
	        catch (Exception e) {
	            return null;
	        }
	    }
		int nextInt() {
			return Integer.parseInt(next());
		}

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

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


import java.io.*;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

/**
 * Created by mostafa on 10/7/17.
 */
public class FireAgain {
    static int n, m, k;
    static int inf = (int) 1e9;
    static class Pair {
        int x, y;
        Pair(int a, int b) {
            x = a; y = b;
        }
    }
    static int[] dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
    static boolean valid(int x, int y) {
        return x >= 0 && x < n && y >= 0 && y < m;
    }
    static int[][] bfs(int[] xs, int[] ys) {
        int[][] dist = new int[n][m];
        for(int i = 0; i < n; i++)
            Arrays.fill(dist[i], inf);
        Queue<Pair> q = new LinkedList<>();
        for(int i = 0; i < k; i++) {
            dist[xs[i]][ys[i]] = 0;
            q.add(new Pair(xs[i], ys[i]));
        }

        while(!q.isEmpty()) {
            Pair p = q.remove();
            for(int d = 0; d < 4; d++) {
                int nx = p.x + dx[d], ny = p.y + dy[d];
                if(valid(nx, ny) && dist[nx][ny] == inf) {
                    dist[nx][ny] = dist[p.x][p.y] + 1;
                    q.add(new Pair(nx, ny));
                }
            }
        }

        return dist;
    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt();
        int[] xs = new int[k], ys = new int[k];
        for(int i = 0; i < k; i++) {
            xs[i] = sc.nextInt() - 1; ys[i] = sc.nextInt() - 1;
        }

        int[][] dist = bfs(xs, ys);

        int x = 0, y = 0;
        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++)
                if(dist[i][j] > dist[x][y]) {
                    x = i; y = j;
                }
        x++; y++;
        PrintWriter out = new PrintWriter("output.txt");
        out.println(x + " " + y);
        out.flush();
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;
        Scanner() throws FileNotFoundException {
            br = new BufferedReader(new FileReader("input.txt"));
        }

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

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


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

    public class Main{
        static class Run implements Runnable{
            //TODO parameters
            final boolean consoleIO = false;
            final String inFile = "input.txt";
            final String outFile = "output.txt";

            int n,m,k;
            int[][] field;
            boolean[][] visited;

            LinkedList<Point> queue;
            int[][] steps = {{0,1},{1,0},{0,-1},{-1,0}};

            void wave() {
                for(Point p:queue)
                    visited[p.y][p.x] = true;

                while(!queue.isEmpty()) {
                    Point cur = queue.removeFirst();
                    for(int i = 0; i < steps.length; ++i) {
                        Point tmp = new Point(cur.x+steps[i][0],cur.y+steps[i][1]);

                        if(ok(tmp)&&!visited[tmp.y][tmp.x]) {
                            queue.add(tmp);
                            visited[tmp.y][tmp.x] = true;
                            field[tmp.y][tmp.x] = field[cur.y][cur.x]+1;
                        }
                    }
                }
            }

            boolean ok(Point p) {
                return p.x>=0 && p.y>=0 && p.x<n && p.y<m;
            }

            @Override
            public void run() {
                n = nextInt();
                m = nextInt();
                k = nextInt();

                queue = new LinkedList<Point>();
                for(int i = 0; i < k; ++i)
                    queue.add(new Point(nextInt()-1,nextInt()-1));

                field = new int[m][n];
                visited = new boolean[m][n];
                wave();

                Point maxP = new Point(0,0);
                int maxV = Integer.MIN_VALUE;

                for(int i = 0; i < m; ++i)
                    for(int j = 0; j < n; ++j)
                        if(field[i][j] > maxV) {
                            maxV = field[i][j];
                            maxP = new Point(j,i);
                        }

                print((maxP.x+1)+" "+(maxP.y+1));
                close();
            }
        //=========================================================================================================================
            BufferedReader in;
            PrintWriter out;
            StringTokenizer strTok;

            Run() {
                if (consoleIO) {
                    initConsoleIO();
                }
                else {
                    initFileIO();
                }
            }

            void initConsoleIO() {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            void initFileIO() {
                try {
                    in = new BufferedReader(new FileReader(inFile));
                    out = new PrintWriter(new FileWriter(outFile));
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            void close() {
                try {
                    in.close();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

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

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

            float nextFloat() {
                return Float.parseFloat(nextToken());
            }

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

            String nextLine() {
                try {
                    return in.readLine();
                } catch (IOException e) {
                    return "__NULL";
                }
            }

            boolean hasMoreTokens() {
                return (strTok == null) || (strTok.hasMoreTokens());
            }

            String nextToken() {
                while (strTok == null || !strTok.hasMoreTokens()) {
                    String line;
                    try {
                        line = in.readLine();
                        strTok = new StringTokenizer(line);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                return strTok.nextToken();
            }

            void cout(Object o){
                System.out.println(o);
            }

            void print(Object o) {
                out.write(o.toString());
            }

            void println(Object o) {
                out.write(o.toString() + '\n');
            }

            void printf(String format, Object... args) {
                out.printf(format, args);
            }

            String sprintf(String format, Object... args) {
            return MessageFormat.format(format, args);
        }
        }

        static class Pair<A, B> {
            A a;
            B b;

            A f() {
                return a;
            }

            B s() {
                return b;
            }

            Pair(A a, B b) {
                this.a = a;
                this.b = b;
            }

            Pair(Pair<A, B> p) {
                a = p.f();
                b = p.s();
            }
        }

        public static void main(String[] args) throws IOException {
            Run run = new Run();
            Thread thread = new Thread(run);
            thread.run();
        }
    }