#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int neg = 1, num = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') neg = -1;
  for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - '0';
  return neg * num;
}
struct node {
  int x, y;
} p[6000010];
int n, m, cnt, a[2010], b[2010], c[2010], d[2010], suf[6000010];
int ans = 2147483647;
bool cmp(node f, node g) { return f.x == g.x ? f.y < g.y : f.x < g.x; }
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++)
    a[i] = read(), b[i] = read(), p[i].x = 0, p[i].y = 0;
  for (int i = 1; i <= m; i++) c[i] = read(), d[i] = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      p[++cnt].x = max(0, c[j] - a[i] + 1);
      p[cnt].y = max(0, d[j] - b[i] + 1);
    }
  sort(p + 1, p + cnt + 1, cmp);
  suf[cnt] = p[cnt].y;
  for (int i = cnt - 1; i >= 1; i--) suf[i] = max(suf[i + 1], p[i].y);
  int pos = 0;
  for (int i = 0; i <= 1e6; i++) {
    while (p[pos + 1].x <= i && pos < cnt) pos++;
    ans = min(ans, i + suf[pos + 1]);
  }
  cout << ans << endl;
  return 0;
}
