#include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-6;
using namespace std;
const int N = 2e6 + 10;
int n, m;
int a[N], b[N], c[N], d[N], r[N];
void solve() {
  cin >> n >> 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];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int raz = c[j] - a[i];
      if (raz >= 0) r[raz] = max(r[raz], d[j] - b[i] + 1);
    }
  }
  for (int i = N - 2; i >= 0; i--) r[i] = max(r[i], r[i + 1]);
  int ans = 1e9;
  for (int i = 0; i < N; i++) {
    ans = min(ans, i + r[i]);
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(6);
  int step;
  step = 1;
  for (int i = 1; i <= step; i++) {
    solve();
  }
}
