#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, m, a[N], b[N], c[N], d[N];
vector<int> add, rmv[N];
bool Never_give_up() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  for (int i = 0; i < m; ++i) cin >> c[i] >> d[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      int cura = max(0, c[j] - a[i] + 1);
      int curb = max(0, d[j] - b[i] + 1);
      if (cura == 0 || curb == 0) continue;
      add.push_back(curb);
      rmv[cura].push_back(curb);
    }
  multiset<int> st;
  st.insert(0);
  int ans = 1e9;
  for (int j : add) st.insert(j);
  for (int i = 0; i < N; ++i) {
    for (int j : rmv[i]) st.erase(st.find(j));
    int x = *st.rbegin();
    ans = min(ans, i + x);
  }
  cout << ans << endl;
  return 0;
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    Never_give_up();
  }
  return 0;
}
