#include <bits/stdc++.h>
using namespace std;
const long long int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353;
const long long inf = 1LL << 61;
const long long int M = 1e6 + 500;
const long long int ths = 1LL << 40;
const long long int NN = 5e3 + 6;
const long long int maxN = 1e6 + 7;
long long int X[maxN];
void solve() {
  long long int n, m;
  cin >> n >> m;
  pair<long long int, long long int> robbers[n], lights[m];
  for (long long int i = 0; i < n; i++) {
    cin >> robbers[i].first >> robbers[i].second;
  }
  for (long long int i = 0; i < m; i++) {
    cin >> lights[i].first >> lights[i].second;
  }
  vector<pair<long long int, long long int>> see;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (lights[j].first < robbers[i].first or
          lights[j].second < robbers[i].second)
        continue;
      see.push_back({lights[j].first - robbers[i].first,
                     lights[j].second - robbers[i].second});
    }
  }
  sort(see.begin(), see.end(),
       [&](const pair<long long int, long long int> a,
           const pair<long long int, long long int> b) {
         return a.first > b.first;
       });
  if (see.empty()) {
    cout << 0 << '\n';
    return;
  }
  long long int j = 0, maxY = 0, ans = see[0].first + 1;
  for (auto it : see) {
    X[it.first] = max(X[it.first], it.second);
  }
  for (long long int i = maxN - 1; i >= 0; i--) {
    maxY = max(maxY, X[i]);
    ans = min(ans, maxY + i + 1);
  }
  cout << ans;
  cout << "\n";
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
