#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10, pi = 3.1415926535898;
const int mod = 1e9 + 7, maxn = 2e3 + 10;
int T, n, m, k, x, y, c[maxn], d[maxn * maxn], ind;
struct P {
  int x, y;
  bool operator<(const P& a) const {
    if (x == a.x) return y < a.y;
    return x < a.x;
  }
} a[maxn], b[maxn], dp[maxn * maxn];
int main(int argc, char const* argv[]) {
  T = 1;
  for (int _ = 1; _ <= T; ++_) {
    int ans = mod;
    x = y = 0;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) {
      scanf("%d %d", &a[i].x, &a[i].y);
    }
    for (int i = 1; i <= m; ++i) {
      scanf("%d %d", &b[i].x, &b[i].y);
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        int xx = 0, yy = 0;
        if (b[j].x >= a[i].x) {
          xx = b[j].x + 1 - a[i].x;
        }
        if (b[j].y >= a[i].y) {
          yy = b[j].y + 1 - a[i].y;
        }
        dp[++ind] = {xx, yy};
      }
    }
    sort(dp + 1, dp + ind + 1);
    d[ind + 1] = 0;
    for (int i = ind; i >= 1; --i) {
      d[i] = max(d[i + 1], dp[i].y);
    }
    for (int i = 0; i <= ind; ++i) {
      ans = min(ans, dp[i].x + d[i + 1]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
