#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> a, b, c, d;
vector<int> v;
int MAX = 1000010;
void solve() {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (c[i] >= a[j]) {
        v[c[i] - a[j]] = max(v[c[i] - a[j]], d[i] - b[j] + 1);
      }
    }
  }
  int result = INT_MAX;
  int cache = 0;
  for (int i = MAX - 1; i >= 0; i--) {
    cache = max(cache, v[i]);
    result = min(result, i + cache);
  }
  cout << result << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  a = vector<int>(n);
  b = vector<int>(n);
  c = vector<int>(m);
  d = vector<int>(m);
  v = vector<int>(MAX, 0);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < m; i++) cin >> c[i] >> d[i];
  solve();
}
