#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3;
const int maxx = 1e6;
const int inf = 0x3f3f3f3f;
int n, m, tot, c[maxx + 10], ans = inf;
pair<int, int> a[maxn + 10], b[maxn + 10];
set<pair<int, int> > s;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &b[i].first, &b[i].second);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (b[j].first >= a[i].first && b[j].second >= a[i].second)
        c[b[j].first - a[i].first] =
            max(c[b[j].first - a[i].first], b[j].second - a[i].second + 1);
  for (int i = maxx; i >= 0; --i) c[i] = max(c[i], c[i + 1]);
  for (int i = 0; i <= maxx; ++i) ans = min(ans, i + c[i]);
  printf("%d\n", ans);
  return 0;
}
