#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > r, s;
  int x, y;
  for (int i = 1; i <= n; ++i) {
    cin >> x >> y;
    r.push_back({x, y});
  }
  for (int i = 1; i <= m; ++i) {
    cin >> x >> y;
    s.push_back({x, y});
  }
  int ans = 1e6 + 10;
  int ystep[1000006] = {0};
  for (int i = 0; i <= n - 1; ++i) {
    for (int j = 0; j <= m - 1; ++j) {
      x = s[j].first - r[i].first;
      y = s[j].second - r[i].second;
      if (x < 0 or y < 0) continue;
      ystep[x] = max(ystep[x], y + 1);
    }
  }
  for (int i = 1000000; i >= 0; i--) {
    ystep[i] = max(ystep[i], ystep[i + 1]);
    ans = min(ans, i + ystep[i]);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) solve();
  return 0;
}
