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 = 100010;
int n, m, q, l[maxn], r[maxn], x[maxn], a[maxn];
long long T, sl[maxn], sr[maxn], sa[maxn], tmp[maxn];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &l[i], &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];
  }
  scanf("%d", &q);
  memset(x, -1, sizeof(x));
  while (q--) {
    int p;
    scanf("%d", &p);
    scanf("%d", &x[m - p + 1]);
  }
  scanf("%lld", &T);
  auto chk = [&](int cnt, int val) {
    bool info = 0;
    long long rem = T;
    for (int i = 1; i <= m; i++) {
      a[i] = max(a[i - 1], x[i]), rem -= a[i];
      if (i >= m - cnt + 1 && ~x[i]) info = 1;
    }
    if (info) {
      if (a[m] < val) return 0;
      for (int i = m - cnt + 1; i <= m; i++) {
        if (~x[i] && a[i] ^ a[m]) return 0;
        rem -= a[m] - a[i], a[i] = a[m];
      }
    } else {
      for (int i = m - cnt + 1; i <= m; i++) {
        if (a[i] < val) rem -= val - a[i], a[i] = val;
      }
      copy(a + 1, a + m + 1, tmp + 1);
    }
    if (rem < 0) return 0;
    auto upd = [&]() {
      for (int i = 1, j = 0; i <= m && rem; i++) {
        if (~x[i] || i >= m - cnt + 1) {
          long long foo = a[i] - a[j + 1], bar = foo * (i - j - 1);
          if (bar > rem) {
            foo = rem / (i - j - 1), bar = foo * (i - j - 1);
            for (int k = i - rem + bar; k < i; k++) a[k]++;
            rem = 0;
          } else {
            rem -= bar;
          }
          for (int k = j + 1; k < i; k++) a[k] += foo;
          j = i;
        }
      }
    };
    long long o = rem;
    upd();
    if (info) {
      if (rem) return 0;
    } else if (rem) {
      copy(tmp + 1, tmp + m + 1, a + 1);
      int pos = cnt;
      while (pos < m && !~x[m - pos]) pos++;
      long long inc = (rem - 1) / pos + 1;
      if (a[m] + inc > n) return 0;
      for (int i = m - cnt + 1; i <= m; i++) a[i] += inc;
      if ((rem = o - inc * cnt) < 0) return 0;
      upd();
      if (rem) return 0;
    }
    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 && a[j] >= n - i) j--;
      if (sl[i] + sa[j] + 1LL * (n - i) * (m - j) < sl[n]) return 0;
      if (sr[i] + sa[j] + 1LL * (n - i) * (m - j) < T) return 0;
    }
    return 1;
  };
  int l = 1, r = m, ans1 = -1, ans2;
  while (l <= r) {
    int mid = (l + r) >> 1;
    chk(mid, 0) ? l = (ans1 = mid) + 1 : r = mid - 1;
  }
  if (!~ans1) puts("-1 -1"), exit(0);
  printf("%d ", ans1), l = 0, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    chk(ans1, mid) ? l = (ans2 = mid) + 1 : r = mid - 1;
  }
  printf("%d\n", ans2);
  return 0;
}