#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n), c(m), d(m);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  int o = n * m;
  vector<pair<int, int>> r(o, {0, 0});
  for (int i = 0, k = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i] <= c[j] && b[i] <= d[j]) {
        r[k++] = {c[j] - a[i] + 1, d[j] - b[i] + 1};
      }
    }
  }
  sort(r.begin(), r.end());
  vector<int> mx(o);
  int mxi = 0;
  for (int i = o - 1; i >= 0; i--) {
    mx[i] = mxi;
    mxi = max(mxi, r[i].second);
  }
  int ans = INT_MAX;
  for (int i = 0; i < o; i++) {
    ans = min(ans, r[i].first + mx[i]);
    swap(r[i].first, r[i].second);
  }
  sort(r.begin(), r.end());
  mxi = 0;
  for (int i = o - 1; i >= 0; i--) {
    mx[i] = mxi;
    mxi = max(mxi, r[i].second);
  }
  for (int i = 0; i < o; i++) {
    ans = min(ans, r[i].first + mx[i]);
  }
  cout << ans << '\n';
  return 0;
}
