#include <bits/stdc++.h>
using namespace std;
const int MAXX = 2e6 + 7;
const int MAXN = 2007;
pair<int, int> light[MAXN], robber[MAXN];
vector<pair<int, int> > oc[MAXX];
multiset<int> jhamela[MAXN];
const int UPTO = 1000007;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> robber[i].first >> robber[i].second;
  for (int i = 1; i <= m; i++) cin >> light[i].first >> light[i].second;
  multiset<int> sobarJhamela;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (robber[i].first <= light[j].first &&
          robber[i].second <= light[j].second) {
        oc[light[j].first - robber[i].first].emplace_back(i, j);
        jhamela[i].insert(light[j].second - robber[i].second);
      }
    }
    if (!jhamela[i].empty()) {
      int cur = *prev(jhamela[i].end());
      sobarJhamela.insert(cur);
    }
  }
  int ans = 1e9 + 7;
  for (int x = 0; x <= UPTO; x++) {
    int tmp = 0;
    if (!sobarJhamela.empty()) tmp += *prev(sobarJhamela.end()) + 1;
    ans = min(ans, x + tmp);
    if (sobarJhamela.empty()) break;
    for (pair<int, int> p : oc[x]) {
      int cur = *prev(jhamela[p.first].end());
      sobarJhamela.erase(sobarJhamela.find(cur));
      jhamela[p.first].erase(jhamela[p.first].find(light[p.second].second -
                                                   robber[p.first].second));
      if (!jhamela[p.first].empty()) {
        cur = *prev(jhamela[p.first].end());
        sobarJhamela.insert(cur);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
