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;
inline long long read() {
  long long x = 0, f = 1, c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
const long long N = 1e5 + 4;
long long n, m, Q, T, mx, sum, ac, ans1, ans2, top;
long long a[N], aa[N], b[N], L[N], R[N], B[N], st[N];
inline bool check_3(long long res) {
  vector<pair<long long, long long> > vec;
  for (long long i = 1, las = 1; i <= m; i++)
    if (a[i] != -1) {
      if (las < i) vec.push_back(make_pair(las, i - 1));
      las = i + 1;
    }
  long long l, r, x, y;
  for (auto v : vec) {
    l = v.first;
    r = v.second;
    if ((r - l + 1) * (B[r + 1] - B[r]) < res) {
      res -= (r - l + 1) * (B[r + 1] - B[r]);
      for (long long i = l; i <= r; i++) B[i] = B[r + 1];
    } else {
      x = res / (r - l + 1);
      y = res - (r - l + 1) * x;
      for (long long i = l; i <= r; i++) B[i] += x;
      for (long long i = 0; i < y; i++) B[r - i]++;
      res = 0;
    }
  }
  return !res;
}
inline long long calc(long long i, long long j, long long *L) {
  return L[j] + B[i] + (n - j) * (m - i);
}
inline long long check_5(long long *L) {
  long long ret = min(L[n], B[m]);
  top = 0;
  for (long long i = 0; i < n; i++) {
    while (top > 1 && (L[st[top]] - L[st[top - 1]]) * (i - st[top]) >=
                          (L[i] - L[st[top]]) * (st[top] - st[top - 1]))
      top--;
    st[++top] = i;
  }
  for (long long i = m - 1, j = 1; i >= 0; i--) {
    while (j < top && calc(i, st[j], L) >= calc(i, st[j + 1], L)) j++;
    ret = min(ret, calc(i, st[j], L));
  }
  return ret;
}
inline bool check_4() {
  for (long long i = 1; i <= m; i++) B[i] += B[i - 1];
  return check_5(L) >= L[n] && check_5(R) >= T;
}
inline bool check_2(long long mid, long long len) {
  ac = 0;
  for (long long i = 1; i <= m; i++) B[i] = b[i];
  long long res = T - sum;
  for (long long i = m - len + 1; i <= m; i++) {
    res -= mid - B[i];
    B[i] = a[i] = mid;
  }
  if (res < 0) return 0;
  if (!check_3(res)) return 1;
  if (check_4()) {
    ac = 1;
    ans1 = len;
    ans2 = mid;
    return 1;
  }
  return 0;
}
inline bool check_1(long long len) {
  ans1 = ans2 = -1;
  long long id = -1;
  for (long long i = m - len + 1; i <= m; i++)
    if (a[i] != -1) {
      if (id != -1 && id != a[i]) return 0;
      id = a[i];
    }
  long long l, r, mid, ret = 0;
  if (id != -1)
    l = r = id;
  else
    l = mx, r = min(n, (T - sum) / len + mx);
  while (l < r) {
    mid = (l + r + 1) >> 1;
    if (check_2(mid, len))
      l = mid;
    else
      r = mid - 1;
    ret |= ac;
  }
  check_2(r, len);
  ret |= ac;
  for (long long i = m - len + 1; i <= m; i++) a[i] = aa[i];
  return ret;
}
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++) {
    L[i] = read();
    R[i] = read();
  }
  Q = read();
  memset(a, -1, sizeof(a));
  for (long long i = 1, x; i <= Q; i++) {
    x = read();
    a[x] = read();
  }
  T = read();
  sort(L + 1, L + n + 1);
  sort(R + 1, R + n + 1);
  for (long long i = 1; i <= n; i++) {
    L[i] += L[i - 1];
    R[i] += R[i - 1];
  }
  reverse(a + 1, a + m + 1);
  memcpy(aa, a, sizeof(a));
  for (long long i = 1; i <= m; i++) {
    if (a[i] != -1) mx = a[i];
    b[i] = mx;
    sum += mx;
  }
  if (sum > T) {
    puts("-1 -1");
    return (0 - 0);
  }
  long long l = 1, r = m, mid;
  while (l < r) {
    mid = (l + r + 1) >> 1;
    if (check_1(mid))
      l = mid;
    else
      r = mid - 1;
  }
  check_1(r);
  cout << ans1 << " " << ans2 << "\n";
  return (0 - 0);
}