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 = 100005;
int n, m, x, Q;
int l[N], r[N], lim[N];
int vQ[N], vC[N];
long long Sum;
void GG() {
  puts("-1 -1");
  exit(0);
}
void init() {
  long long tmp = Sum;
  for (int i = (int)(1); i <= (int)(n); i++) tmp -= l[i];
  if (tmp < 0) GG();
  static int S[N];
  memset(S, 0, sizeof(S));
  for (int i = (int)(1); i <= (int)(n); i++) ++S[l[i] + 1], --S[r[i] + 1];
  for (int i = (int)(1); i <= (int)(m); i++) S[i] += S[i - 1];
  int p = 1;
  for (; tmp > S[p] && p <= m; tmp -= S[p++])
    ;
  if (p > m) GG();
  for (int i = (int)(1); i <= (int)(n); i++)
    vQ[i] = max(l[i], min(p - 1, r[i]));
  for (int i = (int)(1); i <= (int)(n); i++)
    if (vQ[i] == p - 1 && r[i] >= p && tmp) ++vQ[i], --tmp;
  sort(vQ + 1, vQ + n + 1);
}
int check2(int len, int val) {
  for (int i = (int)(0); i <= (int)(m + 1); i++) l[i] = 0, r[i] = n;
  for (int i = (int)(1); i <= (int)(m); i++)
    if (lim[i] != -1) {
      l[i] = max(l[i], lim[i]);
      r[i] = min(r[i], lim[i]);
    }
  for (int i = (int)(1); i <= (int)(len); i++) {
    l[i] = max(l[i], val);
    r[i] = min(r[i], val);
  }
  for (int i = (int)(1); i <= (int)(m + 1); i++) r[i] = min(r[i], r[i - 1]);
  for (int i = (int)(m); i >= (int)(0); i--) l[i] = max(l[i], l[i + 1]);
  for (int i = (int)(0); i <= (int)(m + 1); i++) assert(l[i] <= r[i]);
  long long tmp = Sum;
  for (int i = (int)(1); i <= (int)(m); i++) tmp -= l[i];
  if (tmp < 0) return 1;
  for (int i = (int)(1); i <= (int)(m); i++) tmp -= r[i] - l[i];
  if (tmp > 0) return -1;
  return 0;
}
bool check1(int len, int val) {
  int v = -1;
  for (int i = (int)(1); i <= (int)(len); i++) v = max(v, lim[i]);
  int L = max(0, val), R = (v == -1 ? n : v), ans = -1;
  for (int i = (int)(1); i <= (int)(m); i++) L = max(L, lim[i]);
  for (int i = (int)(1); i <= (int)(len); i++)
    if (lim[i] != -1) R = min(R, lim[i]);
  while (L <= R) {
    int mid = (L + R) / 2;
    int res = check2(len, mid);
    if (res == 0)
      ans = mid, R = mid - 1;
    else
      (res < 0 ? L = mid + 1 : R = mid - 1);
  }
  if (ans == -1) return 0;
  check2(len, ans);
  static int S[N];
  memset(S, 0, sizeof(S));
  long long tmp = Sum;
  for (int i = (int)(1); i <= (int)(m); i++) tmp -= l[i];
  for (int i = (int)(1); i <= (int)(m); i++) ++S[l[i] + 1], --S[r[i] + 1];
  for (int i = (int)(1); i <= (int)(n); i++) S[i] += S[i - 1];
  int p = 1;
  for (; tmp > S[p] && p <= n; tmp -= S[p++])
    ;
  for (int i = (int)(1); i <= (int)(m); i++)
    vC[i] = max(l[i], min(p - 1, r[i]));
  for (int i = (int)(1); i <= (int)(m); i++)
    if (vC[i] == p - 1 && r[i] >= p && tmp) --tmp, ++vC[i];
  sort(vC + 1, vC + m + 1);
  reverse(vC + 1, vC + m + 1);
  long long S1 = 0, S2 = 0;
  p = 0;
  for (int i = (int)(1); i <= (int)(n); i++) {
    for (; p < m && vC[p + 1] == n - i + 1; ++p)
      ;
    S1 += vQ[i];
    S2 += p;
    if (S1 < S2) return 0;
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d%d", &l[i], &r[i]);
  for (int i = (int)(0); i <= (int)(m + 1); i++) lim[i] = -1;
  scanf("%d", &Q);
  for (int i = (int)(1); i <= (int)(Q); i++)
    scanf("%d", &x), scanf("%d", &lim[x]);
  scanf("%lld", &Sum);
  init();
  if (!check1(1, -1)) GG();
  int l = 2, r = m, ans1 = 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check1(mid, -1))
      ans1 = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  int ans2 = 0;
  l = 0, r = n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check1(ans1, mid))
      ans2 = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d %d\n", ans1, ans2);
}