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;
void E() {
  puts("-1 -1");
  exit(0);
}
const int N = 1e5 + 5;
int n, m, l1[N], r1[N], q, x, y, i, j, k, low[N], high[N], a[N], le, ri, md,
    bee;
long long sa[N], sl[N], sr[N], sa1, sa2, t;
bool ck4(long long* s, long long lm) {
  long long mn = 1ll << 60;
  for (i = 0, j = n; i <= m; ++i) {
    for (; j && s[j] + 1ll * (m - i) * (n - j) >
                    s[j - 1] + 1ll * (m - i) * (n - j + 1);
         --j)
      ;
    mn = min(mn, sa[i] + s[j] + 1ll * (m - i) * (n - j));
  }
  return mn >= lm;
}
bool ck3() {
  for (i = 1; i <= m; ++i) sa[i] = sa[i - 1] + a[i];
  return ck4(sl, sl[n]) && ck4(sr, t);
}
bool ck2(int z, int v) {
  long long tot = 0;
  for (i = 1; i <= m; ++i) tot += a[i] = i < z ? low[i] : v;
  if (tot > t) return 0;
  for (i = 1; i < z; i = j) {
    long long ss = 0;
    for (j = i; j < z && high[j] == high[i]; ++j) ss += low[j];
    int zz = j == z ? min(v, high[i]) : high[i];
    if (tot + 1ll * (j - i) * zz - ss >= t) {
      for (; j > i && low[j - 1] == high[j - 1];) ss -= low[--j];
      if (j > i) {
        long long ff = t - tot + ss;
        for (k = i; k < j; ++k) a[k] = ff / (j - i);
        for (k = 1; k <= ff % (j - i); ++k) ++a[j - k];
      }
      tot = t;
      break;
    }
    tot += 1ll * (j - i) * zz - ss;
    for (k = i; k < j; ++k) a[k] = zz;
  }
  return tot >= t && ck3();
}
bool ck(int z) {
  long long v;
  if (z <= bee)
    v = low[m];
  else
    v = max(0ll, t - sa2 + m - bee - 1) / (m - bee) + low[m];
  if (v > n) return 0;
  return ck2(z, v);
}
int calc(int z) {
  if (z <= bee) return low[m];
  int l, r = high[m], mid;
  if (z <= bee)
    l = low[m];
  else
    l = max(0ll, t - sa2 + m - bee - 1) / (m - bee) + low[m];
  for (; l < r;) mid = l + r + 1 >> 1, ck2(z, mid) ? l = mid : r = mid - 1;
  return l;
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) scanf("%d%d", l1 + i, r1 + i);
  sort(l1 + 1, l1 + n + 1);
  for (i = 1; i <= n; ++i) sl[i] = sl[i - 1] + l1[i];
  sort(r1 + 1, r1 + n + 1);
  for (i = 1; i <= n; ++i) sr[i] = sr[i - 1] + r1[i];
  memset(high + 1, -1, m << 2);
  memset(low + 1, -1, m << 2);
  scanf("%d", &q);
  for (; q--;) scanf("%d%d", &x, &y), x = m - x + 1, low[x] = high[x] = y;
  high[m + 1] = n;
  for (i = m; i; --i) -1 == high[i] ? high[i] = high[i + 1] : 0;
  for (i = 1; i <= m; ++i) -1 == low[i] ? low[i] = low[i - 1] : 0;
  for (i = m; i; --i)
    if (high[i] >= low[m]) le = i;
  ri = m;
  for (i = 1; i <= m; ++i)
    if (low[i] == high[i] && low[i] == low[m]) bee = i;
  for (i = 1; i <= m; ++i) sa1 += low[i], sa2 += i <= bee ? high[i] : low[i];
  scanf("%lld", &t);
  if (t < sa1) E();
  for (; le < ri;) {
    md = le + ri >> 1;
    if (ck(md))
      ri = md;
    else
      le = md + 1;
  }
  if (!ck(le)) E();
  printf("%d %d\n", m - le + 1, calc(le));
  return 0;
}