#include <bits/stdc++.h>
using namespace std;
const int N = 1000007;
int max_req[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > a(n), b(m);
  for (auto &first : a) {
    cin >> first.first >> first.second;
  }
  for (auto &first : b) {
    cin >> first.first >> first.second;
  }
  int ans = 1e9;
  for (auto first : a) {
    for (auto second : b) {
      if (first.first > second.first || first.second > second.second) continue;
      int dx = second.first - first.first;
      int dy = second.second - first.second;
      max_req[dx] = max(max_req[dx], dy + 1);
    }
  }
  int tet = 0;
  for (int i = N - 1; i >= 0; i--) {
    tet = max(tet, max_req[i]);
    ans = min(ans, i + tet);
  }
  cout << ans;
}
