#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void boostIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
}
bool isPrime(int x) {
  if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
  for (int i = 5; i * i <= x; i += 6)
    if (x % i == 0 || x % (i + 2) == 0) return 0;
  return 1;
}
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
template <typename T>
inline T getint() {
  T val = 0;
  char c;
  bool neg = false;
  while ((c = getchar()) && !(c >= '0' && c <= '9')) {
    neg |= c == '-';
  }
  do {
    val = (val * 10) + c - '0';
  } while ((c = getchar()) && (c >= '0' && c <= '9'));
  return val * (neg ? -1 : 1);
}
int Mod = 1e9 + 7;
long long int inf = 2e18;
int32_t main() {
  boostIO();
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> B(n);
  for (int i = 0; i < (n); ++i) {
    cin >> B[i].first >> B[i].second;
  }
  vector<pair<int, int>> P(m);
  for (int i = 0; i < (m); ++i) {
    cin >> P[i].first >> P[i].second;
  }
  vector<int> X(1e6 + 2);
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (m); ++j) {
      int bx, by;
      tie(bx, by) = B[i];
      int px, py;
      tie(px, py) = P[j];
      int x = px - bx;
      if (x < 0) continue;
      X[x] = max(X[x], py - by + 1);
    }
  }
  int Max = 0;
  for (int i = 1e6; i >= 0; --i) {
    Max = max(X[i], Max);
    X[i] = Max;
  }
  int ans = inf;
  for (int i = 0; i <= 1e6 + 1; ++i) {
    ans = min(ans, X[i] + i);
  }
  cerr << "ans = ";
  cout << ans << '\n';
  cerr << '\n' << "RUNTIME: " << 1.0 * clock() / CLOCKS_PER_SEC << " s" << '\n';
  return 0;
  ;
}
