#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct segtree{
private:
  ll siz;
  vector<ll> node;
public:
  segtree(ll n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,0);
  }
  void upd(int p,int x){
    p+=siz-1;
    node[p]=x;
    while(p>0){
      p=(p-1)/2;
      node[p]=max(node[2*p+1],node[2*p+2]);
    }
  }
  ll max_v(ll a,ll b,ll p,ll l,ll r){
    if(a<=l&&r<=b) return node[p];
    if(r<=a||b<=l) return 0;
    ll mid=(l+r)/2;
    return max(max_v(a,b,2*p+1,l,mid),max_v(a,b,2*p+2,mid,r));
  }
  ll max_q(ll a){
    return max_v(a,siz,0,0,siz);
  }
};
int main(){
  vector<ll> vec;
  vector<P> points;
  ll h,w,n;
  cin>>h>>w>>n;
  for(int i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    points.push_back(P(x,y));
    vec.push_back(x);
  }
  vec.push_back(0);
  points.push_back(P(0,0));
  sort(vec.begin(),vec.end());
  sort(points.begin(),points.end());
// cout<<0<<" "<<points[0].first<<" "<<points[0].second<<endl;
  segtree seg=segtree(n+5);
  for(int i=1;i<=n;i++){
    seg.upd(i,points[i].second);
  //  c//out<<i<<" "<<points[i].first<<" "<<points[i].second<<endl;
  }
  ll ans=17441744174417;
  for(int i=0;i<vec.size();i++){
    ll kans=vec[i];
    ll p=lower_bound(points.begin(),points.end(),P(kans+1,0))-points.begin();
  //  cout<<i<<" "<<kans<<" "<<p<<" "<<seg.max_q(p)<<endl;
    kans+=seg.max_q(p);
    ans=min(ans,kans);
  }
//  ans=min(ans,vec[])
  cout<<ans<<endl;
}

