#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 50;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int n, m;
struct node {
  int x, y;
} a[maxn], b[maxn];
int up[maxn * 10];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &b[i].x, &b[i].y);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i].x <= b[j].x && a[i].y <= b[j].y) {
        int dx = max(0, b[j].x - a[i].x);
        int dy = max(0, b[j].y - a[i].y + 1);
        up[dx] = max(up[dx], dy);
      }
    }
  }
  for (int i = maxn * 10; i >= 0; i--) {
    up[i] = max(up[i], up[i + 1]);
  }
  int ans = inf;
  for (int i = 0; i <= maxn * 10; i++) {
    ans = min(ans, i + up[i]);
  }
  printf("%d\n", ans);
  return 0;
}
