#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge {
  ll to, cost;
};
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
class SegmentTree_max {
  long long n;
  vector<long long> seg;

 public:
  void seg_init(int n_) {
    n = 1;
    while (n < n_) {
      n *= 2;
    }
    seg.assign(2 * n - 1, 0);
  }
  void update(int k, long long a) {
    k += n - 1;
    seg[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      seg[k] = max(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }
  long long get_max(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) {
      return get_max(a, b, k, 0, n);
    }
    if (r <= a || b <= l) {
      return 0;
    }
    if (a <= l && r <= b) {
      return seg[k];
    } else {
      long long maxl = get_max(a, b, 2 * k + 1, l, (l + r) / 2);
      long long maxr = get_max(a, b, 2 * k + 2, (l + r) / 2, r);
      return max(maxl, maxr);
    }
  }
};
void solve() {
  int N, M;
  cin >> N >> M;
  vector<pair<ll, ll> > R(N), S(M);
  for (ll i = 0; i < N; i++) {
    cin >> R[i].first >> R[i].second;
  }
  for (ll i = 0; i < M; i++) {
    cin >> S[i].first >> S[i].second;
  }
  SegmentTree_max segtree;
  segtree.seg_init(1000001);
  ll ans = INF;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < M; j++) {
      if (segtree.get_max(max(-1LL, S[j].first - R[i].first),
                          max(-1LL, S[j].first - R[i].first) + 1) <
          max(-1LL, S[j].second - R[i].second) + 1) {
        segtree.update(max(-1LL, S[j].first - R[i].first),
                       max(-1LL, S[j].second - R[i].second) + 1);
      }
    }
  }
  for (ll i = 0; i < 1000001; i++) {
    chmin(ans, i + segtree.get_max(i, 1000001));
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int q = 1;
  while (q--) {
    solve();
  }
}
