#include <bits/stdc++.h>
using namespace std;
int yChange[1000005];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n);
  vector<pair<int, int>> b(m);
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  for (int i = 0; i < m; i++) cin >> b[i].first >> b[i].second;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i].first <= b[j].first && a[i].second <= b[j].second) {
        yChange[b[j].first - a[i].first] = max(yChange[b[j].first - a[i].first],
                                               b[j].second - a[i].second + 1);
      }
    }
  }
  int maxm = 0;
  int res = INT_MAX;
  for (int i = 1000000; i >= 0; i--) {
    maxm = max(maxm, yChange[i]);
    res = min(res, i + maxm);
  }
  cout << res << "\n";
}
