#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > a(n), b(m);
  for (long long i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  for (long long i = 0; i < m; i++) cin >> b[i].first >> b[i].second;
  vector<pair<long long, long long> > p;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (b[j].first >= a[i].first && b[j].second >= a[i].second) {
        p.push_back(
            {b[j].first - a[i].first + 1, b[j].second - a[i].second + 1});
      }
    }
  }
  if ((long long)p.size() == 0) {
    cout << 0 << '\n';
    return 0;
  }
  sort((p).begin(), (p).end());
  long long ans = 1e9, c = 0;
  vector<long long> arr;
  for (long long i = (long long)p.size() - 1; i >= 0; i--) {
    c = max(c, p[i].second);
    arr.push_back(c);
  }
  reverse((arr).begin(), (arr).end());
  ans = min(ans, arr[0]);
  for (long long i = 0; i < (long long)p.size(); i++) {
    if (i < (long long)p.size() - 1) ans = min(ans, p[i].first + arr[i + 1]);
  }
  ans = min(ans, p[(long long)p.size() - 1].first);
  cout << ans << '\n';
}
