#include <bits/stdc++.h>
const long long mod = 1e18 + 7;
long long mul(long long a, long long b) { return (a * b) % mod; };
long long add(long long a, long long b) { return (a + b) % mod; };
long long sub(long long a, long long b) { return (a - b + mod) % mod; };
long long ksm(long long a, long long n) {
  long long ret = 1;
  for (; n; n /= 2, a = mul(a, a))
    if (n & 1) ret = mul(ret, a);
  return ret;
}
long long Div(long long a, long long b) { return mul(a, ksm(b, mod - 2)); };
const int MAXN = 200010;
const long long inf = 1e9 + 7;
using namespace std;
int main() {
  long long t = 1, n = 1, m;
  while (t--) {
    cin >> n >> m;
    vector<pair<int, int>> a(n), b(m);
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    for (int i = 0; i < m; i++) cin >> b[i].first >> b[i].second;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++) {
      pair<int, int> p = a[i];
      for (int j = 0; j < m; j++) {
        int x = 0, y = 0;
        if (b[j].first >= p.first) {
          x = max(x, b[j].first - p.first + 1);
        }
        if (b[j].second >= p.second) {
          y = max(y, b[j].second - p.second + 1);
        }
        v.push_back({x, y});
      }
    }
    sort(v.begin(), v.end());
    vector<int> pv(v.size());
    pv[v.size() - 1] = v.back().second;
    for (int i = v.size() - 2; i >= 0; i--) pv[i] = max(pv[i + 1], v[i].second);
    int ans = pv[0];
    for (int i = 0; i < v.size() - 1; i++) {
      ans = min(ans, v[i].first + pv[i + 1]);
    }
    ans = min(ans, v.back().first);
    cout << ans << endl;
  }
}
