#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
int a[N];
int b[N];
int c[N];
int d[N];
int h[N];
int n, m;
void solve() {
  cin >> n;
  cin >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> c[i] >> d[i];
  }
  int ans = 1e9;
  int mx = 0;
  int my = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int x = c[j] - a[i];
      int y = d[j] - b[i];
      if (x >= 0) h[x] = max(h[x], y + 1);
    }
  }
  for (int i = N - 2; i >= 0; i--) {
    h[i] = max(h[i], h[i + 1]);
    ans = min(ans, h[i] + i);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  int TC = 1;
  while (TC--) solve();
  return 0;
}
