#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
int a[N], b[N], c[N], d[N];
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &c[i], &d[i]);
  }
  vector<pair<int, int> > v;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i] > c[j] || b[i] > d[j]) continue;
      v.push_back(pair<int, int>(c[j] - a[i] + 1, d[j] - b[i] + 1));
    }
  }
  sort(v.begin(), v.end());
  int ans = 1e9, mx = 0;
  for (int i = (int)v.size() - 1; i >= 0; --i) {
    ans = min(ans, v[i].first + mx);
    mx = max(mx, v[i].second);
  }
  ans = min(ans, mx);
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}
