#include <bits/stdc++.h>
using namespace std;
long long inp, Inp;
long long i1, i2, i3, i4, i5, i6, i7, i8;
long long MOD = 998244353, MOD1 = (long long)1e9 + 7, MOD2 = (long long)1e9 + 9;
long long MOD3 = (long long)1e9 + 21;
double eps = 1e-9;
long long TMP =
    (chrono::high_resolution_clock::now().time_since_epoch().count() % MOD +
     MOD) %
    MOD;
auto STTMP = chrono::steady_clock::now();
int main() {
  ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.precision(20);
  srand((unsigned int)TMP);
  long long N, M;
  cin >> N >> M;
  vector<pair<int, int>> rob, d;
  for (int n = (0); n < (N); n++) {
    cin >> i1 >> i2;
    rob.push_back({i1, i2});
  }
  for (int m = (0); m < (M); m++) {
    cin >> i1 >> i2;
    for (int n = (0); n < (N); n++) {
      d.push_back({max(i1 - rob.at(n).first + 1, 0ll),
                   max(i2 - rob.at(n).second + 1, 0ll)});
    }
  }
  std::sort(d.begin(), d.end());
  vector<pair<int, int>> dpr = {d.at(0)};
  long long X = N * M;
  for (int i = (1); i < (X); i++) {
    if (d.at(i).first == dpr.back().first) {
      dpr.back() = d.at(i);
    } else {
      dpr.push_back(d.at(i));
    }
  }
  std::swap(d, dpr);
  multiset<int> ms;
  for (int x = (0); x < (d.size()); x++) {
    ms.insert(d.at(x).second);
  }
  int res = *ms.rbegin();
  res = min(res, d.back().first);
  for (int x = (0); x < ((long long)d.size() - 1); x++) {
    int add = d.at(x).first;
    ms.erase(ms.find(d.at(x).second));
    res = min(res, *ms.rbegin() + add);
  }
  cout << res << "\n";
  return 0;
}
