#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<long long> highestY(1e6 + 5);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n), b(n), c(m), d(m);
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (long long i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      long long xDiff = c[j] - a[i];
      if (xDiff >= 0) {
        highestY[xDiff] = max(highestY[xDiff], d[j] - b[i] + 1);
      }
    }
  }
  long long ans = 1e10;
  long long maxYtillHere = -1;
  for (long long x = highestY.size() - 1; x >= 0; x--) {
    ans = min(ans, maxYtillHere + x + 1);
    maxYtillHere = max(maxYtillHere, highestY[x]);
  }
  ans = min(ans, maxYtillHere);
  cout << ans;
  return 0;
}
