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>
const int N = 100054;
int n, T;
int lb[N], ub[N], score[N], real[N];
bool fixed[N];
long long S, Lb[N], Ub[N];
inline void down(long long &x, const long long y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x < y ? y : x; }
inline long long max(const long long x, const long long y) {
  return x < y ? y : x;
}
inline bool test(int *_arg) {
  int i, j;
  long long sum = 0;
  for (i = 0, j = n; i <= T; ++i, sum += j) {
    for (; j && _arg[j - 1] <= i; sum += _arg[--j] - i)
      ;
    if (sum < max(Lb[i], S - Ub[i])) return false;
  }
  return true;
}
inline long long allocate(int l, int r, int limit, long long sum) {
  int width = r - l + 1, base = real[l];
  lldiv_t res;
  down(sum, (long long)limit * width), res = lldiv(sum, width);
  std::fill(real + l, real + (l + res.rem), base + res.quot + 1);
  std::fill(real + (l + res.rem), real + (r + 1), base + res.quot);
  return sum;
}
bool check(int count, int value) {
  int i, j, _1, _rg, _crg;
  long long remain;
  _1 = std::count(score, score + count, -1);
  _rg = max(*std::max_element(score, score + n), 0);
  _crg = std::count(score, score + count, _rg);
  if (_1 + _crg != count || (_crg && _rg < value)) return false;
  if (!_crg) _rg = value;
  std::fill(real, real + count, _rg), memset(fixed, true, count);
  for (i = n - 1; i >= count; --i)
    real[i] = ((fixed[i] = (bool)~score[i]) ? score[i] : real[i + 1]);
  if ((remain = -std::accumulate(real, real + n, -S)) < 0) return false;
  for (j = n, i = n - 1; i >= count; --i)
    if (fixed[i])
      i == --j ||
          (remain -= allocate(i + 1, j, real[i] - real[j], remain), j = i);
  if (count != j)
    remain -= allocate(count, j - 1, real[count - 1] - real[j], remain);
  return remain ? !_crg && (value += (remain + j - 1) / j) <= T &&
                      check(count, value)
                : test(real);
}
int main() {
  int i, c, L, R, M;
  scanf("%d%d", &T, &n), memset(score, -1, (n + 1) << 2), score[n] = 0;
  for (i = 0; i < T; ++i) scanf("%d%d", lb + i, ub + i);
  std::sort(lb, lb + T, std::greater<int>());
  std::sort(ub, ub + T, std::greater<int>());
  for (i = T - 1; i >= 0; --i)
    Lb[i] = Lb[i + 1] + lb[i], Ub[i] = Ub[i + 1] + ub[i];
  for (i = T; i >= 0; --i) Lb[i] = *Lb - Lb[i];
  for (scanf("%d", &L); L; --L) scanf("%d%d", &i, &R), score[--i] = R;
  scanf("%lld", &S);
  for (L = 0, R = n; L < R; check(M = (L + R + 1) / 2, 0) ? L = M : (R = M - 1))
    ;
  if (!L) return puts("-1 -1"), 0;
  for (c = L, L = 0, R = T; L < R;
       check(c, M = (L + R + 1) / 2) ? L = M : (R = M - 1))
    ;
  printf("%d %d\n", c, L);
  return 0;
}