#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-7;
const unsigned long long hashp = 131;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 2e3 + 100;
pair<int, int> a[maxn], b[maxn];
pair<int, int> arr[maxn * maxn];
int mx[maxn * maxn], cnt;
void solve() {
  int _ = 1;
  while (_--) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; (i) <= (n); i++) scanf("%d%d", &a[i].first, &a[i].second);
    for (int j = 1; (j) <= (m); j++) {
      scanf("%d%d", &b[j].first, &b[j].second);
      for (int i = 1; (i) <= (n); i++) {
        arr[++cnt] = pair<int, int>(max(0, b[j].first - a[i].first + 1),
                                    max(0, b[j].second - a[i].second + 1));
      }
    }
    sort(arr + 1, arr + cnt + 1);
    for (int i = cnt; i; i--) {
      mx[i] = max(mx[i + 1], arr[i].second);
    }
    int ans = inf;
    for (int i = 0; (i) < (cnt + 1); i++)
      ans = min(ans, arr[i].first + mx[i + 1]);
    cout << ans << endl;
  }
}
int main() {
  solve();
  return 0;
}
