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 MAXN = 1e5 + 5;
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
int n, m, q, l[MAXN], r[MAXN], x[MAXN];
int a[MAXN];
long long t, sa[MAXN], sl[MAXN], sr[MAXN];
bool check() {
  for (int i = 1; i <= m; i++) sa[i] = sa[i - 1] + a[i];
  for (int i = 0, j = m; i <= n; i++) {
    while (j >= 1 && a[j] >= n - i) j--;
    if (sl[i] + sa[j] + 1ll * (n - i) * (m - j) < sl[n]) return false;
    if (sr[i] + sa[j] + 1ll * (n - i) * (m - j) < t) return false;
  }
  return true;
}
bool check(int cnt, int val) {
  long long sum = 0;
  bool flg = true;
  for (int i = 1; i <= m; i++) {
    a[i] = max(a[i - 1], x[i]), sum += a[i];
    if (m - i + 1 <= cnt) flg &= x[i] == -1;
  }
  if (!flg) {
    if (a[m] < val) return false;
    for (int i = 1; i <= cnt; i++) {
      if (x[m - i + 1] != -1 && a[m - i + 1] != a[m]) return false;
      sum += a[m] - a[m - i + 1];
      a[m - i + 1] = a[m];
    }
  } else {
    for (int i = 1; i <= cnt; i++) {
      if (a[m - i + 1] < val) {
        sum += val - a[m - i + 1];
        a[m - i + 1] = val;
      }
    }
  }
  if (sum > t) return false;
  sum = t - sum;
  long long bak = sum;
  for (int i = 1, last = 0; i <= m; i++)
    if (x[i] != -1 || m - i + 1 <= cnt) {
      int rng = i - last - 1, inc = a[i] - a[last];
      if (1ll * inc * rng <= sum) {
        sum -= 1ll * inc * rng;
        for (int j = last + 1; j <= i - 1; j++) a[j] += inc;
      } else {
        inc = sum / rng, sum -= 1ll * inc * rng;
        for (int j = last + 1; j <= i - 1; j++) {
          a[j] += inc;
          if (i - j <= sum) a[j]++;
        }
        sum = 0;
        break;
      }
      last = i;
    }
  if (!flg) {
    if (sum != 0) return false;
  } else {
    if (sum != 0) {
      int tmp = cnt;
      while (tmp < m && x[m - tmp] == -1) tmp++;
      long long inc = (sum - 1) / tmp + 1;
      for (int i = 1; i <= m; i++) {
        a[i] = max(a[i - 1], x[i]);
        if (m - i + 1 <= cnt) chkmax(a[i], val);
      }
      if (a[m] + inc > n) return false;
      for (int i = 1; i <= cnt; i++) a[m - i + 1] += inc;
      sum = bak - inc * cnt;
      if (sum < 0) return false;
      for (int i = 1, last = 0; i <= m; i++)
        if (x[i] != -1 || m - i + 1 <= cnt) {
          int rng = i - last - 1, inc = a[i] - a[last];
          if (1ll * inc * rng <= sum) {
            sum -= 1ll * inc * rng;
            for (int j = last + 1; j <= i - 1; j++) a[j] += inc;
          } else {
            inc = sum / rng, sum -= 1ll * inc * rng;
            for (int j = last + 1; j <= i - 1; j++) {
              a[j] += inc;
              if (i - j <= sum) a[j]++;
            }
            sum = 0;
            break;
          }
          last = i;
        }
      if (sum != 0) return false;
    }
  }
  return check();
}
int main() {
  read(n), read(m);
  for (int i = 1; i <= n; i++) read(l[i]), read(r[i]);
  sort(l + 1, l + n + 1);
  sort(r + 1, r + n + 1);
  for (int i = 1; i <= n; i++) {
    sl[i] = sl[i - 1] + l[i];
    sr[i] = sr[i - 1] + r[i];
  }
  for (int i = 1; i <= m; i++) x[i] = -1;
  read(q);
  for (int i = 1; i <= q; i++) {
    int pos;
    read(pos);
    read(x[m - pos + 1]);
  }
  read(t);
  if (!check(1, 0)) {
    puts("-1 -1");
    return 0;
  }
  int l = 1, r = m;
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (check(mid, 0))
      l = mid;
    else
      r = mid - 1;
  }
  int cnt = l;
  l = 0, r = n;
  cout << cnt << ' ';
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (check(cnt, mid))
      l = mid;
    else
      r = mid - 1;
  }
  cout << l << endl;
  return 0;
}