#include <bits/stdc++.h>
using namespace std;
namespace santongding {
void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > p(n), lp(m);
  int mx = 0;
  for (auto &x : p) cin >> x.first >> x.second;
  for (auto &x : lp) cin >> x.first >> x.second;
  vector<pair<int, int> > lis;
  for (auto x : p) {
    for (auto lx : lp) {
      if (lx.first >= x.first && lx.second >= x.second)
        lis.push_back({lx.first - x.first, lx.second - x.second}),
            mx = max(lx.second - x.second, mx);
    }
  }
  if (!lis.size()) {
    puts("0");
    return;
  }
  sort(lis.begin(), lis.end(), greater<pair<int, int> >());
  int ans = 1e9;
  pair<int, int> np = lis[0];
  ans = min(ans, np.first + 1);
  ans = min(ans, mx + 1);
  for (int i = 0; i < lis.size(); i++) {
    if (np.second >= lis[i].second) continue;
    ans = min(ans, lis[i].first + np.second + 2);
    np = lis[i];
  }
  cout << ans << endl;
}
}  // namespace santongding
int main() {
  int t = 1;
  while (t--) {
    santongding::solve();
  }
}
