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;
const int N = 1e5 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, m, q, lim[N], l[N], r[N], s[N], tp;
long long t, a[N], b[N], w[N];
struct line {
  int k;
  long long b;
  long long f(int x) { return 1ll * k * x + b; }
} st[N];
bool check(line a, line b, line c) {
  return 1ll * (a.b - b.b) * (c.k - a.k) <= 1ll * (a.b - c.b) * (b.k - a.k);
}
bool check3(long long *a, long long lim) {
  tp = 0;
  for (int i = 0; i <= n; i++) {
    line l = (line){i, a[i] - 1ll * m * i};
    while (tp > 1 && check(st[tp - 1], st[tp], l)) --tp;
    st[++tp] = l;
  }
  for (int i = 0; i <= m; i++) {
    while (tp > 1 && st[tp - 1].f(i) <= st[tp].f(i)) --tp;
    if (st[tp].f(i) + w[i] - 1ll * n * i + 1ll * n * m < lim) return 0;
  }
  return 1;
  return 1;
}
int check2(int cnt, int val) {
  for (int i = 1; i <= m; i++) l[i] = 0, r[i] = n;
  for (int i = 1; i <= m; i++)
    if (~lim[i]) l[i] = r[i] = lim[i];
  for (int i = 1; i <= cnt; i++) l[i] = r[i] = val;
  for (int i = m - 1; i; i--) l[i] = max(l[i], l[i + 1]);
  for (int i = 2; i <= m; i++) r[i] = min(r[i], r[i - 1]);
  long long tmp = t;
  for (int i = 1; i <= m; i++) tmp -= l[i];
  if (tmp < 0) return 1;
  tmp = t;
  for (int i = 1; i <= m; i++) tmp -= r[i];
  if (tmp > 0) return -1;
  return 0;
}
bool check(int cnt, int val) {
  int L = val, R = n, ans = -1;
  for (int i = 1; i <= cnt; i++)
    if (~lim[i]) R = min(R, lim[i]);
  for (int i = 1; i <= m; i++) L = max(L, lim[i]);
  while (L <= R) {
    int mid = (L + R) >> 1, t = check2(cnt, mid);
    if (t > 0)
      R = mid - 1;
    else if (t == 0)
      ans = mid, R = mid - 1;
    else
      L = mid + 1;
  }
  if (!~ans) return 0;
  check2(cnt, ans);
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= m; i++) ++s[l[i]], --s[r[i]];
  for (int i = 1; i <= n; i++) s[i] += s[i - 1];
  long long tmp = t;
  int p = 0;
  for (int i = 1; i <= m; i++) tmp -= l[i];
  for (int i = 0;; i++) {
    if (tmp >= s[i])
      tmp -= s[i];
    else {
      p = i;
      break;
    }
  }
  for (int i = 1; i <= m; i++) w[i] = max(l[i], min(p, r[i]));
  for (int i = 1; i <= m; i++)
    if (w[i] == p && r[i] > p && tmp) --tmp, ++w[i];
  sort(w + 1, w + m + 1);
  for (int i = 1; i <= m; i++) w[i] += w[i - 1];
  return check3(b, t) && check3(a, a[n]);
}
int main() {
  memset(lim, -1, sizeof(lim));
  cin >> n >> m;
  for (int i = 1; i <= n; i++) a[i] = gi(), b[i] = gi();
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) a[i] += a[i - 1], b[i] += b[i - 1];
  cin >> q;
  for (int i = 1, x; i <= q; i++) x = gi(), lim[x] = gi();
  cin >> t;
  int l = 0, r = m;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (check(mid, 0))
      l = mid;
    else
      r = mid - 1;
  }
  if (!l) return cout << -1 << ' ' << -1, 0;
  int ans1 = l;
  l = 0, r = n;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (check(ans1, mid))
      l = mid;
    else
      r = mid - 1;
  }
  cout << ans1 << ' ' << l << '\n';
  return 0;
}