#include <bits/stdc++.h>
using namespace std;
inline int random(int _min, int _max) {
  static bool first = true;
  if (first) {
    srand(time(NULL));
    first = false;
  }
  return _min + rand() % ((_max + 1) - _min);
}
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
inline long long int exp(long long int a, long long int b) {
  a %= 1000000007;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a % 1000000007;
    }
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
inline int add(int a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
inline int multi(long long int a, long long int b) {
  a *= b;
  if (a >= 1000000007) a %= 1000000007;
  return a;
}
inline int on_bit(int N, int pos) { return N = N | (1 << pos); }
inline int off_bit(int N, int pos) { return N = N & ~(1 << pos); }
inline bool check_bit(long long int N, int pos) {
  return (bool)(N & (1 << pos));
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > a(n), b(m);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = {x, y};
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    b[i] = {x, y};
  }
  vector<int> mark(1000010);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i].first <= b[j].first)
        mark[b[j].first - a[i].first] =
            max(mark[b[j].first - a[i].first], b[j].second - a[i].second + 1);
    }
  }
  int ans = 2000010, y = 0;
  for (int x = 1000000; x >= 0; x--) {
    y = max(y, mark[x]);
    ans = min(ans, x + y);
  }
  cout << ans << "\n";
  return 0;
}
