#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx2")
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int RANDOM =
    chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
  int operator()(int x) const { return x ^ RANDOM; }
};
const int mod = 1e9 + 7;
void solve(int tt) {
  int n, m;
  cin >> n >> m;
  vector<array<int, 2>> r(n), s(m);
  for (auto& it : r) {
    cin >> it[0] >> it[1];
  }
  for (auto& it : s) {
    cin >> it[0] >> it[1];
  }
  const int mxN = 1e6 + 5;
  vector<int> mx(mxN);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (r[i][0] > s[j][0]) continue;
      mx[s[j][0] - r[i][0]] = max(mx[s[j][0] - r[i][0]], s[j][1] - r[i][1] + 1);
    }
  }
  int ans = 1e9, yshi = -1e9;
  for (int xshi = mxN - 1; ~xshi; xshi--) {
    yshi = max(yshi, mx[xshi]);
    ans = min(ans, xshi + yshi);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt = 0, t = 1;
  while (t--) {
    solve(++tt);
  }
  cerr << "processor time: " << clock() / (double)CLOCKS_PER_SEC << "s    ";
  return 0;
}
