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 n, m, Q;
long long T;
std::vector<long long> req, l, r;
std::vector<long long> fill(std::vector<long long>& req) {
  std::vector<long long> ans(m + 1);
  long long tem = T;
  for (long long i = m; i; i--) {
    ans[i] = 0;
    if (i < m) ans[i] = ans[i + 1];
    if (~req[i]) ans[i] = req[i];
    tem -= ans[i];
  }
  if (tem < 0) return std::vector<long long>();
  for (long long i = m, last = m + 1; tem && ~i; i--) {
    if (~req[i]) {
      long long mx = (i < m) ? (last - 1 - i) * (req[i] - ans[i + 1]) : 0;
      if (mx <= tem) {
        for (long long j = i + 1; j < last; j++) ans[j] = req[i];
        tem -= mx;
      } else {
        for (long long j = i + 1; j < last; j++)
          ans[j] +=
              (tem / (last - 1 - i)) + ((tem % (last - 1 - i)) >= (j - i));
        tem = 0;
      }
      last = i;
    }
  }
  if (tem) return std::vector<long long>();
  return ans;
}
long long q[100001], h, t;
bool check(std::vector<long long> a, std::vector<long long> b) {
  long long n = (long long)a.size() - 1, m = (long long)b.size() - 1;
  h = t = 0;
  for (long long i = 2; i <= n; i++) a[i] += a[i - 1];
  for (long long i = 2; i <= m; i++) b[i] += b[i - 1];
  for (long long i = 1; i <= n; i++) a[i] -= 1ll * i * m;
  for (long long i = 1; i <= m; i++) b[i] -= 1ll * i * n;
  for (long long i = 1; i <= m; i++) {
    while (h < t - 1 && (1ll * (b[q[t]] - b[i]) * (q[t] - q[t - 1]) >=
                         1ll * (b[q[t - 1]] - b[q[t]]) * (i - q[t])))
      --t;
    q[++t] = i;
  }
  for (long long i = 1; i <= n; i++) {
    while (h < t - 1 && (b[q[t]] + q[t] * i) >= (b[q[t - 1]] + q[t - 1] * i))
      --t;
    if (b[q[t]] + q[t] * i < a[n] - a[i]) return 0;
  }
  return 1;
}
bool judge(long long x, long long y = -1) {
  std::vector<long long> Req = req;
  if (~y) {
    for (long long i = 1; i <= x; i++) Req[i] = y;
  }
  std::vector<long long> now = fill(Req);
  if (now.empty()) return 0;
  if (now[1] != now[x]) {
    for (long long i = 1; i <= x; i++)
      if (~req[i] && req[i] != now[1]) return 0;
    for (long long i = 1; i <= x; i++) Req[i] = now[1];
    now = fill(Req);
    if (now.empty()) return 0;
  }
  std::reverse(now.begin() + 1, now.end());
  return check(l, now) & check(now, r);
}
signed main() {
  scanf("%lld%lld", &n, &m);
  l.resize(n + 1), r.resize(n + 1);
  for (long long i = 1; i <= n; i++) scanf("%lld%lld", &l[i], &r[i]);
  std::sort(l.begin() + 1, l.end());
  std::sort(r.begin() + 1, r.end());
  req.resize(m + 1);
  for (long long i = 1; i <= m; i++) req[i] = -1;
  req[0] = 0x7f7f7f7f;
  scanf("%lld", &Q);
  for (long long i = 1, a, b; i <= Q; i++) {
    scanf("%lld%lld", &a, &b);
    req[a] = b;
  }
  scanf("%lld", &T);
  long long l = 1, r = m, mid, ans = -1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (judge(mid))
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  if (!~ans) {
    printf("-1 -1");
    return 0;
  }
  for (long long i = 1; i <= ans; i++)
    if (~req[i]) {
      printf("%lld %lld\n", ans, req[i]);
      return 0;
    }
  l = fill(req)[1], r = n;
  long long ans1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (judge(ans, mid))
      ans1 = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%lld %lld\n", ans, ans1);
}