#include <bits/stdc++.h>
using namespace std;
int dp[1000006];
struct node {
  int a, b;
} r[2005];
struct mode {
  int c, d;
} rr[2005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &r[i].a, &r[i].b);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &rr[i].c, &rr[i].d);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (rr[j].c >= r[i].a && rr[j].d >= r[i].b) {
        dp[rr[j].c - r[i].a] = max(dp[rr[j].c - r[i].a], rr[j].d - r[i].b + 1);
      }
    }
  }
  int maxn = 0, ans = 10000010, ends = 1000000;
  for (int i = ends; i >= 0; i--) {
    maxn = max(maxn, dp[i]);
    ans = min(ans, maxn + i);
  }
  printf("%d\n", ans);
  return 0;
}
