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>
long long read() {
  long long r = 0, t = 1, c = getchar();
  while (c < '0' || c > '9') {
    t = c == '-' ? -1 : 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    r = r * 10 + c - 48;
    c = getchar();
  }
  return r * t;
}
void nosol() {
  printf("-1 -1\n");
  exit(0);
}
const int N = 100010;
int n, m;
long long t, T;
int _l[N], _r[N], a[N];
long long A[N];
int q, p[N], s[N], P[N], S[N], id[N];
int d[N];
int l, r;
int In(int x, int l, int r) { return std::min(std::max(x, l), r); }
bool check(int P, int v) {
  memset(d, 0, sizeof(d));
  p[0] = P;
  s[0] = v;
  t = T;
  for (int i = (1), end_i = (P); i <= end_i; i++) d[i] = v;
  for (int i = (1), end_i = (q); i <= end_i; i++)
    if (p[i] <= P && v != s[i]) return 0;
  if (p[1] <= P) p[0] = 0;
  for (int i = (1), end_i = (q); i <= end_i; i++) d[p[i]] = s[i];
  for (int i = (m), end_i = (P + 1); i >= end_i; i--)
    if (!d[i]) d[i] = d[i + 1];
  for (int i = (1), end_i = (m); i <= end_i; i++) t -= d[i];
  if (t < 0) return 0;
  for (int i = (q), end_i = (0); i >= end_i; i--) {
    int L = std::max(P, p[i]) + 1, R = p[i + 1] - 1;
    if (L <= R && t <= (long long)(R - L + 1) * (s[i] - s[i + 1])) {
      long long k = t / (R - L + 1);
      for (int j = (L), end_j = (R); j <= end_j; j++) {
        d[j] += k;
        t -= k;
      }
      for (int j = (L), end_j = (L + t - 1); j <= end_j; j++) {
        d[j]++;
        t--;
      }
      break;
    } else
      for (int j = (L), end_j = (R); j <= end_j; j++) {
        t -= s[i] - d[j];
        d[j] = s[i];
      }
  }
  if (t) return 0;
  for (int i = (1), end_i = (P); i <= end_i; i++)
    if (d[i] != v) return 0;
  for (int i = (1), end_i = (m - 1); i <= end_i; i++)
    if (d[i] < d[i + 1]) return 0;
  for (int i = (1), end_i = (q); i <= end_i; i++)
    if (d[p[i]] != s[i]) return 0;
  long long S = 0;
  for (int i = (1), end_i = (m); i <= end_i; i++) {
    S += d[i];
    if (S > A[i]) return 0;
  }
  return 1;
}
int main() {
  n = read();
  m = read();
  for (int i = (1), end_i = (n); i <= end_i; i++) {
    _l[i] = read();
    _r[i] = read();
  }
  q = read();
  for (int i = (1), end_i = (q); i <= end_i; i++) {
    P[i] = read();
    S[i] = read();
    id[i] = i;
  }
  std::sort(id + 1, id + q + 1, [&](int a, int b) { return P[a] < P[b]; });
  for (int i = (1), end_i = (q); i <= end_i; i++) {
    p[i] = P[id[i]];
    s[i] = S[id[i]];
  }
  s[0] = n;
  p[q + 1] = m + 1;
  T = t = read();
  l = 1;
  r = m;
  while (l <= r) {
    int mid = (l + r) >> 1;
    long long _t = t;
    for (int i = (1), end_i = (n); i <= end_i; i++)
      _t -= (a[i] = In(mid - 1, _l[i], _r[i]));
    for (int i = (1), end_i = (n); i <= end_i; i++)
      if (_t > 0 && a[i] != _r[i] && a[i] == mid - 1) {
        a[i]++;
        _t--;
      }
    if (_t == 0)
      break;
    else if (_t > 0)
      l = mid + 1;
    else
      r = mid - 1;
    if (l > r) nosol();
  }
  for (int i = (1), end_i = (n); i <= end_i; i++)
    if (a[i]) A[a[i]]++;
  for (int i = (m), end_i = (2); i >= end_i; i--) A[i - 1] += A[i];
  for (int i = (1), end_i = (m); i <= end_i; i++) A[i] += A[i - 1];
  if (!check(0, n)) nosol();
  int v = d[1], l = 2, r = m + 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid, v))
      l = mid + 1;
    else
      r = mid;
  }
  int P = l - 1;
  l = v + 1;
  r = n + 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(P, mid))
      l = mid + 1;
    else
      r = mid;
  }
  assert(check(P, l - 1));
  printf("%d %d\n", P, l - 1);
  return 0;
}