Problem: As a professional private tutor, Kuroni has to gather statistics of an exam. Kuroni has appointed you to complete this important task. You must not disappoint him.

The exam consists of n questions, and m students have taken the exam. Each question was worth 1 point. Question i was solved by at least l_i and at most r_i students. Additionally, you know that the total score of all students is t.

Furthermore, you took a glance at the final ranklist of the quiz. The students were ranked from 1 to m, where rank 1 has the highest score and rank m has the lowest score. Ties were broken arbitrarily.

You know that the student at rank p_i had a score of s_i for 1 ≤ i ≤ q.

You wonder if there could have been a huge tie for first place. Help Kuroni determine the maximum number of students who could have gotten as many points as the student with rank 1, and the maximum possible score for rank 1 achieving this maximum number of students.

Input

The first line of input contains two integers (1 ≤ n, m ≤ 10^{5}), denoting the number of questions of the exam and the number of students respectively.

The next n lines contain two integers each, with the i-th line containing l_{i} and r_{i} (0 ≤ l_{i} ≤ r_{i} ≤ m).

The next line contains a single integer q (0 ≤ q ≤ m). 

The next q lines contain two integers each, denoting p_{i} and s_{i} (1 ≤ p_{i} ≤ m, 0 ≤ s_{i} ≤ n). It is guaranteed that all p_{i} are distinct and if p_{i} ≤ p_{j}, then s_{i} ≥ s_{j}.

The last line contains a single integer t (0 ≤ t ≤ nm), denoting the total score of all students.

Output

Output two integers: the maximum number of students who could have gotten as many points as the student with rank 1, and the maximum possible score for rank 1 achieving this maximum number of students. If there is no valid arrangement that fits the given data, output -1 -1.

Examples

Input


5 4
2 4
2 3
1 1
0 1
0 0
1
4 1
7


Output


3 2


Input


5 6
0 6
0 6
2 5
6 6
4 6
1
3 3
30


Output


-1 -1

Note

For the first sample, here is one possible arrangement that fits the data:

Students 1 and 2 both solved problems 1 and 2.

Student 3 solved problems 2 and 3.

Student 4 solved problem 4.

The total score of all students is T = 7. Note that the scores of the students are 2, 2, 2 and 1 respectively, which satisfies the condition that the student at rank 4 gets exactly 1 point. Finally, 3 students tied for first with a maximum score of 2, and it can be proven that we cannot do better with any other arrangement.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MAXN = 100100;
long long work[MAXN];
long long pwork[MAXN];
vector<long long> make(vector<long long> l, vector<long long> u,
                       long long total) {
  assert(l.size() == u.size());
  long long ls = 0;
  long long us = 0;
  for (long long a : l) ls += a;
  for (long long a : u) us += a;
  if (total < ls || total > us) return {};
  for (long long i = 0; i < MAXN; i++) work[i] = 0;
  for (long long a : l) work[a]++;
  for (long long b : u) work[b]--;
  long long cur = 0;
  for (long long a : l) cur += a;
  long long s = 0;
  long long psum = 0;
  while (true) {
    psum += work[s];
    if (cur <= total && total <= cur + psum) {
      break;
    }
    cur += psum;
    s++;
  }
  vector<long long> ret(l.size());
  long long extra = total - cur;
  for (long long i = 0; i < (long long)ret.size(); i++) {
    if (extra && l[i] <= s && s + 1 <= u[i]) {
      ret[i] = s + 1;
      extra--;
    } else if (l[i] <= s && s <= u[i]) {
      ret[i] = s;
    } else if (s < l[i]) {
      ret[i] = l[i];
    } else {
      ret[i] = u[i];
    }
    total -= ret[i];
  }
  assert(total == 0);
  return ret;
}
vector<long long> set_make(vector<long long> l, vector<long long> u,
                           long long cnt, long long val, long long total) {
  for (long long j = 0; j < cnt; j++) l[j] = max(l[j], val);
  for (long long& x : u) x = min(x, val);
  for (long long j = 0; j < (long long)l.size(); j++)
    if (u[j] < l[j]) return {};
  vector<long long> res = make(l, u, total);
  return res;
}
bool okay(vector<long long> a, vector<long long> b) {
  if (a.empty()) return false;
  sort(b.begin(), b.end());
  long long n = (long long)a.size();
  long long m = (long long)b.size();
  long long asum = 0;
  long long j = 0;
  long long bsum = 0;
  for (long long i = 1; i <= n; i++) {
    asum += a[i - 1];
    while (j < m && b[j] <= i) {
      bsum += b[j];
      j++;
    }
    if (asum > bsum + (m - j) * i) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> l(n), u(n);
  for (long long i = 0; i < n; i++) cin >> l[i] >> u[i];
  vector<long long> lb(m, 0);
  vector<long long> ub(m, n);
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long p, s;
    cin >> p >> s;
    p--;
    lb[p] = s;
    ub[p] = s;
  }
  for (long long i = 1; i < m; i++) ub[i] = min(ub[i], ub[i - 1]);
  for (long long i = m - 2; i >= 0; i--) lb[i] = max(lb[i], lb[i + 1]);
  long long s = 0;
  long long e = m + 1;
  long long TOTAL;
  cin >> TOTAL;
  vector<long long> probs = make(l, u, TOTAL);
  vector<long long> people = make(lb, ub, TOTAL);
  if (probs.empty() || people.empty()) {
    cout << -1 << ' ' << -1 << '\n';
    return 0;
  }
  while (s + 1 < e) {
    long long mid = (s + e) / 2;
    long long maxcnt = mid;
    vector<long long> res = set_make(lb, ub, maxcnt, people[0], TOTAL);
    if (okay(res, probs)) {
      s = mid;
    } else {
      e = mid;
    }
  }
  if (s == 0) {
    cout << -1 << ' ' << -1 << '\n';
    return 0;
  }
  long long cnt = s;
  long long sv = people[0] - 1;
  long long ev = n + 1;
  while (sv + 1 < ev) {
    long long mv = (sv + ev) / 2;
    vector<long long> res = set_make(lb, ub, cnt, mv, TOTAL);
    if (okay(res, probs)) {
      sv = mv;
    } else {
      ev = mv;
    }
  }
  assert(sv >= people[0]);
  cout << cnt << ' ' << sv << '\n';
}