#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(nullptr));
const long long INF = 1e18, P = 1e9 + 7, N = 2e5 + 10;
const long double EPS = 1e-9;
int32_t main() {
  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), c;
  for (long long i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  multiset<long long> st;
  for (long long i = 0; i < m; i++) {
    cin >> b[i].first >> b[i].second;
  }
  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) {
        continue;
      }
      long long x = b[j].first - a[i].first + 1,
                y = b[j].second - a[i].second + 1;
      c.push_back({x, y});
      st.insert(y);
    }
  }
  sort(c.begin(), c.end());
  if (c.size() == 0) {
    cout << 0;
    return 0;
  }
  long long ans = *--st.end();
  for (long long i = 0; i < c.size(); i++) {
    st.erase(st.find(c[i].second));
    long long mx = (st.size() == 0 ? 0 : *--st.end());
    ans = min(ans, c[i].first + mx);
  }
  cout << ans << "\n";
  return 0;
}
