#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n], b[n], c[m], d[m];
  vector<pair<long long int, long long int> > v;
  for (long long int i = 0; i < (n); i++) cin >> a[i] >> b[i];
  for (long long int i = 0; i < (m); i++) cin >> c[i] >> d[i];
  for (long long int i = 0; i < (n); i++) {
    for (long long int j = 0; j < (m); j++) {
      long long int dx = c[j] - a[i] + 1, dy = d[j] - b[i] + 1;
      if (dx > 0 && dy > 0) v.push_back(make_pair(dx, dy));
    }
  }
  if (v.size()) {
    sort((v).begin(), (v).end());
    long long int ans = 1e6 + 1, ptr = v.size() - 1, maxdy = 0;
    for (long long int i = 1000001; i > (-1); i--) {
      while (ptr > -1 && v[ptr].first > i) {
        maxdy = max(maxdy, v[ptr].second);
        ptr--;
      }
      ans = min(ans, i + maxdy);
    }
    cout << ans;
  } else
    cout << 0;
}
int main() {
  long long int t = 1;
  while (t--) {
    solve();
  }
}
