#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)

int main(){
    int W,H,N;
    cin >> W >> H >> N;
    vector<int> MAX_X(H,0), MAX_Y(W,0);
    rep(i,N){
        int x,y;
        cin >> x >> y ;
        MAX_X[y] = max(MAX_X[y], x);
        MAX_Y[x] = max(MAX_Y[x], y);
    }

    for(int y=H-2;y>=0;y--) MAX_X[y] = max(MAX_X[y], MAX_X[y+1]);
    for(int x=W-2;x>=0;x--) MAX_Y[x] = max(MAX_Y[x], MAX_Y[x+1]);

    for(int y=0;y<H-1;y++) MAX_X[y] = MAX_X[y+1];
    for(int x=0;x<W-1;x++) MAX_Y[x] = MAX_Y[x+1];

    MAX_X[H-1] = 0;
    MAX_Y[W-1] = 0;

    int ans = 1e9;
    for(int y=0;y<H;y++) ans = min(ans, y+MAX_X[y]);
    for(int x=0;x<W;x++) ans = min(ans, x+MAX_Y[x]);

    cout << ans << endl;
}

