#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 100;
struct rob {
  int x, y;
} re[maxn];
struct light {
  int x, y;
} li[maxn];
int v[1000060];
int main(void) {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> re[i].x >> re[i].y;
  }
  for (int j = 1; j <= m; j++) {
    cin >> li[j].x >> li[j].y;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (li[j].x - re[i].x >= 0 && li[j].y - re[i].y >= 0) {
        v[li[j].x - re[i].x] =
            max(v[li[j].x - re[i].x], (li[j].y - re[i].y + 1));
      }
    }
  }
  int ans = 1e7;
  int r = -1e7;
  for (int i = 1000000; i >= 0; i--) {
    r = max(r, v[i]);
    ans = min(ans, r + i);
  }
  cout << ans << endl;
  return 0;
}
