#include <bits/stdc++.h>
using namespace std;
void init() {
  freopen("a.in", "r", stdin);
  cout.precision(9);
}
const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e6 + 34;
int q[N];
int a[N], b[N], c[N], d[N];
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (int j = 0; j < m; j++) cin >> c[j] >> d[j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int x = c[j] - a[i];
      q[x] = max(q[x], d[j] - b[i] + 1);
    }
  int cur = 0;
  for (int i = 1000000; i >= 0; i--) {
    cur = max(cur, q[i]);
    q[i] = cur;
  }
  int ans = INF;
  for (int i = 0; i <= 1000000; i++) ans = min(ans, i + q[i]);
  cout << ans;
}
int main() {
  solve();
  return 0;
}
