#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005, maxp = 1000005;
int n, m;
pair<int, int> rob[maxn], lights[maxn];
int pre[maxn], post[maxn];
int f[maxp] = {0}, maxf[maxp] = {0};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> rob[i].first >> rob[i].second;
  }
  for (int i = 1; i <= m; ++i) {
    cin >> lights[i].first >> lights[i].second;
  }
  sort(lights + 1, lights + 1 + m);
  post[0] = 1, pre[m + 1] = m;
  for (int i = 1; i <= m; ++i) {
    pre[i] = i - 1;
    post[i] = i + 1;
  }
  for (int i = 1; i <= m; ++i) {
    while (pre[i] && lights[pre[i]].first <= lights[i].first &&
           lights[pre[i]].second <= lights[i].second) {
      post[pre[pre[i]]] = i;
      pre[i] = pre[pre[i]];
    }
  }
  for (int i = 1; i <= n; ++i) {
    int j = post[0];
    while (j != m + 1 && lights[j].first < rob[i].first) j = post[j];
    if (j == m + 1) continue;
    f[0] = max(f[0], lights[j].second - rob[i].second + 1);
    while (j != m + 1) {
      f[lights[j].first - rob[i].first] =
          max(f[lights[j].first - rob[i].first],
              lights[j].second - rob[i].second + 1);
      j = post[j];
    }
  }
  for (int i = maxp - 2; i >= 0; --i) {
    maxf[i] = max(maxf[i + 1], f[i]);
  }
  int ans = 0x3f3f3f3f;
  for (int i = 0; i < maxp; ++i) {
    ans = min(ans, i + maxf[i]);
  }
  cout << ans << endl;
  return 0;
}
