#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[2005];
pair<int, int> b[2005];
int maxv[1000005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].first);
    scanf("%d", &a[i].second);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i].first);
    scanf("%d", &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) {
        int id = b[j].first - a[i].first;
        maxv[id] = max(maxv[id], b[j].second - a[i].second + 1);
      }
    }
  }
  int ans = 1 << 30;
  int Max = 0;
  for (int i = 1e6; i >= 0; i--) {
    Max = max(Max, maxv[i]);
    ans = min(ans, Max + i);
  }
  cout << ans;
  return 0;
}
