#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353ll;
const long long int P = 1000000007ll;
const long long int N = 2005ll;
bool cmp(char x, char y) { return x > y; }
pair<long long int, long long int> a[N], b[N];
long long int c[1000005];
void solve() {
  long long int n, m;
  cin >> n >> m;
  for (long long int i = (1); i <= (n); ++i) cin >> a[i].first >> a[i].second;
  for (long long int i = (1); i <= (m); ++i) cin >> b[i].first >> b[i].second;
  for (long long int i = (1); i <= (n); ++i)
    for (long long int j = (1); j <= (m); ++j) {
      long long int x = b[j].first - a[i].first;
      if (x >= 0) c[x] = max(c[x], b[j].second - a[i].second + 1);
    }
  long long int ans = 1e18;
  for (long long int i = 1e6; i >= 0; --i) {
    c[i] = max(c[i], c[i + 1]);
    ans = min(ans, c[i] + i);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
