#include <bits/stdc++.h>
using namespace std;
long long PI = acos(-1.0), MOD = 1000000007;
long long n, m, x, y, z, k, sol, sum, ans, l, r, xx, yy;
long long a[2000000], b[2000000], mem[1000][1000];
vector<pair<long long, long long> > v;
vector<pair<long long, long long> > v1;
vector<pair<long long, long long> > v2;
vector<pair<long long, long long> > vp;
map<long long, long long> ma;
string s1, s2, s;
set<long long> st;
char c;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v1.push_back({x, y});
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    v2.push_back({x, y});
  }
  for (int i = 0; i < n; i++) {
    x = v1[i].first, y = v1[i].second;
    for (int q = 0; q < m; q++) {
      if (x > v2[q].first || y > v2[q].second) continue;
      a[v2[q].first - x] = max(a[v2[q].first - x], v2[q].second - y + 1);
    }
  }
  x = 0, sol = 1e12;
  for (int i = 1e6; i >= 0; i--) {
    x = max(x, a[i]);
    sol = min(sol, x + i);
  }
  cout << sol << endl;
  return 0;
}
