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;
struct Point {
  long long x, y;
  Point() {}
  Point(long long a, long long b) : x(a), y(b) {}
  Point operator-(Point b) { return Point(x - b.x, y - b.y); }
};
long long cross(Point x, Point y) { return x.x * y.y - x.y * y.x; }
Point st[100005];
int top;
long long calc(Point x, long long k) { return x.x * k + x.y; }
void insert(Point p) {
  while (top > 1 && cross(p - st[top], st[top] - st[top - 1]) >= 0) top--;
  st[++top] = p;
}
int a[100005], b[100005], num[100005];
long long up[100005];
void convex(int n, int m, long long lb, long long rb) {
  long long s = 0;
  for (int i = 1; i <= n; i++) s += a[i];
  top = 0;
  for (int i = n; i >= 0; i--) {
    insert(Point(n - i, s));
    s -= a[i];
  }
  int r = 1;
  for (int i = 1; i <= m; i++) {
    while (r < top && calc(st[r + 1], m - i) <= calc(st[r], m - i)) r++;
    up[i] = max(up[i], lb - calc(st[r], m - i));
  }
  s = 0;
  for (int i = 1; i <= n; i++) s += b[i];
  top = 0;
  for (int i = n; i >= 0; i--) {
    insert(Point(n - i, s));
    s -= b[i];
  }
  r = 1;
  for (int i = 1; i <= m; i++) {
    while (r < top && calc(st[r + 1], m - i) <= calc(st[r], m - i)) r++;
    up[i] = max(up[i], rb - calc(st[r], m - i));
  }
}
bool solve1(int n, long long rb) {
  long long s1 = 0, s2 = 0, maxn = 0;
  int last2 = 0;
  for (int i = 1; i <= n; i++)
    if (num[i] != -1) {
      if (maxn > num[i]) return 0;
      s1 += num[i];
      s2 += (long long)(i - last2 - 1) * (num[i] - maxn);
      if (s1 < up[i]) {
        if (s1 + s2 < up[i]) return 0;
        s2 -= up[i] - s1;
        s1 = up[i];
      }
      last2 = i;
      maxn = num[i];
    } else {
      s1 += maxn;
      if (s1 < up[i]) {
        if (s1 + s2 >= up[i]) {
          s2 -= up[i] - s1;
          s1 = up[i];
        } else {
          long long v = up[i] - s1 - s2, t = (v + i - last2 - 1) / (i - last2);
          maxn += t;
          s1 = up[i];
          s2 = t * (i - last2) - v;
        }
      }
    }
  return s1 <= rb && (s1 + s2 >= rb || num[n] != -1);
}
int solve2(int n, int k, long long rb) {
  long long s1 = 0, s2 = 0, maxn = 0;
  int last2 = 0;
  for (int i = 1; i <= n - k; i++)
    if (num[i] != -1) {
      s1 += num[i];
      s2 += (long long)(i - last2 - 1) * (num[i] - maxn);
      if (s1 < up[i]) {
        s2 -= up[i] - s1;
        s1 = up[i];
      }
      last2 = i;
      maxn = num[i];
    } else {
      s1 += maxn;
      if (s1 < up[i]) {
        if (s1 + s2 >= up[i]) {
          s2 -= up[i] - s1;
          s1 = up[i];
        } else {
          long long v = up[i] - s1 - s2, t = (v + i - last2 - 1) / (i - last2);
          maxn += t;
          s1 = up[i];
          s2 = t * (i - last2) - v;
        }
      }
    }
  long long t = -1;
  for (int i = n - k + 1; i <= n; i++)
    if (num[i] != -1) {
      if (t == -1)
        t = num[i];
      else if (t != num[i])
        return -1;
    }
  if (t == -1) t = (rb - s1) / k;
  long long v = rb - (long long)t * k;
  if (s1 > v || maxn > t) return -1;
  return (s1 + s2 + (long long)(n - k - last2) * (t - maxn) >= v) ? t : -1;
}
int main() {
  memset(num, 255, sizeof(num));
  int n, m;
  scanf("%d%d", &n, &m);
  long long lb = 0, s = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    lb += a[i];
    s += b[i];
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  int k;
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    num[m - x + 1] = y;
  }
  long long rb = 0;
  scanf("%lld", &rb);
  if (lb > rb || s < rb) {
    puts("-1 -1");
    return 0;
  }
  convex(n, m, lb, rb);
  if (!solve1(m, rb)) {
    puts("-1 -1");
    return 0;
  }
  int l = 1, r = m;
  while (l < r) {
    int mid = ((l + r) >> 1) + 1;
    if (solve2(m, mid, rb) != -1)
      l = mid;
    else
      r = mid - 1;
  }
  int ans = solve2(m, l, rb);
  printf("%d %d\n", l, ans);
  return 0;
}