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 = 100005;
int n, m, q, first, pos, ans, head, tail;
int l[MAXN];
int r[MAXN];
int b[MAXN];
int Q[MAXN];
int fix[MAXN];
long long T;
long long suml[MAXN];
long long sumr[MAXN];
long long sumb[MAXN];
void init() {
  for (int i = 1; i <= n; i++) {
    suml[i] = l[i];
    sumr[i] = r[i];
  }
  sort(suml + 1, suml + n + 1);
  sort(sumr + 1, sumr + n + 1);
  for (int i = 1; i <= n; i++) {
    suml[i] += suml[i - 1];
    sumr[i] += sumr[i - 1];
  }
  reverse(suml, suml + n + 1);
  reverse(sumr, sumr + n + 1);
  fix[m + 1] = 0;
  for (int i = 1; i <= m + 1; i++)
    if (~fix[i]) {
      pos = i;
      first = fix[i];
      break;
    }
}
long long getval(long long *a, long long *b) {
  head = 1;
  tail = 0;
  for (int i = m; i >= 0; i--) {
    while (head < tail && (b[Q[tail]] - b[Q[tail - 1]]) * (Q[tail] - i) >=
                              (b[i] - b[Q[tail]]) * (Q[tail - 1] - Q[tail]))
      tail--;
    Q[++tail] = i;
  }
  long long res = 1e18;
  for (int i = 0; i <= n; i++) {
    while (head < tail && (long long)Q[head] * i + b[Q[head]] >=
                              (long long)Q[head + 1] * i + b[Q[head + 1]])
      head++;
    res = min(res, a[i] + (long long)Q[head] * i + b[Q[head]]);
  }
  return res;
}
long long MaxFlow() {
  sumb[0] = 0;
  for (int i = 1; i <= m; i++) sumb[i] = b[i];
  reverse(sumb + 1, sumb + m + 1);
  for (int i = 1; i <= m; i++) sumb[i] += sumb[i - 1];
  reverse(sumb, sumb + m + 1);
  if (getval(suml, sumb) < suml[0]) return -1;
  return getval(sumr, sumb);
}
bool putMIN(int L) {
  for (int i = 1; i <= L; i++) {
    if (~fix[i] && fix[i] != first) return 0;
    b[i] = first;
  }
  int MN = 0;
  for (int i = m + 1; i > L; i--) {
    if (~fix[i]) MN = fix[i];
    b[i] = MN;
  }
  return 1;
}
long long fill(int L, long long TT) {
  int nxt = m + 1;
  for (int i = m; i >= L; i--)
    if (~fix[i] || i == L) {
      if (nxt == i + 1) {
        nxt = i;
        continue;
      }
      int low = b[nxt], high = b[i],
          inc = min(TT / (nxt - i - 1), (long long)high - low), rem = 0;
      if (inc < high - low) rem = TT % (nxt - i - 1);
      for (int j = i + 1; j < nxt; j++) b[j] += inc + (j - i <= rem);
      TT -= (long long)inc * (nxt - i - 1) + rem;
      nxt = i;
    }
  return TT;
}
bool ok(int L, int V) {
  if (!putMIN(L)) return 0;
  long long TT = T;
  for (int i = 1; i <= m; i++) TT -= b[i];
  if (TT < 0) return 0;
  long long used = TT;
  TT = fill(L, TT);
  used -= TT;
  if (TT > 0 && L >= pos) return 0;
  if (!TT && b[1] < V) return 0;
  if (TT > 0) {
    long long MN = 1e18;
    int inc = -1;
    for (int i = 0; i <= n - b[1]; i++) {
      if (b[1] + i < V) continue;
      if ((long long)i * (pos - 1) < TT) continue;
      long long dis = max(0ll, (long long)i * L - TT);
      if (dis < MN) {
        MN = dis;
        inc = i;
      }
    }
    if (used < MN) return 0;
    putMIN(L);
    fill(L, used - MN);
    TT += MN;
    int add = 0, len = 0, add2 = 0;
    for (int i = 1; i <= inc; i++) {
      if (TT - pos + 1 >= (long long)(inc - i) * L &&
          TT - pos + 1 <= (long long)(inc - i) * (pos - 1)) {
        add++;
        TT -= pos - 1;
        continue;
      }
      len = pos - 1 - ((long long)(inc - i) * L - (TT - pos + 1));
      TT -= len;
      add2 = TT / L;
      break;
    }
    for (int i = 1; i < pos; i++) b[i] += add + (i <= len) + (i <= L) * add2;
  }
  return MaxFlow() == T;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d", &l[i], &r[i]);
  scanf("%d", &q);
  memset(fix, -1, sizeof(fix));
  for (int p, s, i = 1; i <= q; i++) {
    scanf("%d%d", &p, &s);
    fix[p] = s;
  }
  scanf("%lld", &T);
  init();
  int low = 1, high = m;
  if (!ok(1, 0)) {
    puts("-1 -1");
    return 0;
  }
  while (low < high) {
    int mid = low + high + 1 >> 1;
    if (ok(mid, 0))
      low = mid;
    else
      high = mid - 1;
  }
  ans = low;
  low = first, high = n;
  while (low < high) {
    int mid = low + high + 1 >> 1;
    if (ok(ans, mid))
      low = mid;
    else
      high = mid - 1;
  }
  printf("%d %d\n", ans, low);
  return 0;
}