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 char nc() {
  return getchar();
  static char buf[100000], *l = buf, *r = buf;
  return l == r && (r = (l = buf) + fread(buf, 1, 100000, stdin), l == r)
             ? EOF
             : *l++;
}
template <class T>
void read(T &x) {
  x = 0;
  int f = 1, ch = nc();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = nc();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 - '0' + ch;
    ch = nc();
  }
  x *= f;
}
template <class T>
inline bool Cmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
const long long INF = 1e18;
const int maxn = 1e5 + 50;
int n, m, q;
long long T;
int mx;
int re;
int a[maxn];
int b[maxn];
int tmp[maxn];
long long sL;
long long sum;
long long B[maxn];
long long L[maxn];
long long R[maxn];
bool check0(long long rest) {
  vector<pair<int, int> > rec;
  int now = 1;
  for (int i = 1; i <= m; ++i) {
    if (a[i] != -1) {
      if (now < i) rec.push_back(make_pair(now, i - 1));
      now = i + 1;
    }
  }
  for (int i = 0; i < rec.size() && rest; ++i) {
    int l = rec[i].first, r = rec[i].second;
    long long d = (long long)(r - l + 1) * (B[r + 1] - B[r]);
    if (rest >= d) {
      rest -= d;
      for (int j = l; j <= r; ++j) B[j] = B[r + 1];
    } else {
      int x = rest / (r - l + 1), y = rest - (long long)x * (r - l + 1);
      for (int j = l; j <= r; ++j) {
        B[j] += x;
        if (r - j + 1 <= y) ++B[j];
      }
      rest = 0;
    }
  }
  return rest == 0;
}
long long cal(long long *A) {
  static int sta[maxn];
  int top = 0;
  for (int i = 0; i <= n; ++i) {
    while (top > 1 && (A[sta[top]] - A[sta[top - 1]]) * (i - sta[top]) >=
                          (A[i] - A[sta[top]]) * (sta[top] - sta[top - 1]))
      --top;
    sta[++top] = i;
  }
  long long mn = INF;
  for (int i = 0; i <= m; ++i) {
    while (top > 1 && (long long)(m - i) * (sta[top] - sta[top - 1]) <=
                          (A[sta[top]] - A[sta[top - 1]]))
      --top;
    int x = sta[top];
    Cmin(mn, A[x] + B[i] + (long long)(n - x) * (m - i));
  }
  return mn;
}
bool check1() {
  for (int i = 1; i <= m; ++i) B[i] += B[i - 1];
  assert(B[m] == T);
  return cal(L) >= sL && cal(R) >= T;
}
bool sol(int len) {
  int rec = -1;
  for (int i = m - len + 1; i <= m; ++i)
    if (a[i] != -1) {
      if (rec != -1 && rec != a[i]) return 0;
      rec = a[i];
    }
  int l, r;
  bool ok = 0;
  if (rec != -1)
    l = r = rec;
  else
    l = mx, r = min((long long)n, (T - sum) / len + mx);
  while (l <= r) {
    int mid = (l + r) >> 1;
    for (int i = 1; i <= m; ++i) B[i] = b[i];
    long long rest = T - sum;
    for (int i = m - len + 1; i <= m; ++i) {
      rest -= mid - B[i];
      B[i] = mid;
      tmp[i] = a[i], a[i] = mid;
    }
    if (rest < 0) {
      r = mid - 1;
    } else if (!check0(rest)) {
      l = mid + 1;
    } else {
      if (check1())
        ok = 1, re = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    for (int i = m - len + 1; i <= m; ++i) {
      a[i] = tmp[i];
    }
  }
  return ok;
}
int main() {
  read(n), read(m);
  for (int i = 1; i <= n; ++i) {
    read(L[i]), read(R[i]);
  }
  read(q);
  memset(a, -1, sizeof(a));
  for (int i = 1; i <= q; ++i) {
    int p, s;
    read(p), read(s);
    a[p] = s;
  }
  read(T);
  sort(L + 1, L + n + 1);
  sort(R + 1, R + n + 1);
  for (int i = 1; i <= n; ++i) {
    L[i] += L[i - 1];
    R[i] += R[i - 1];
  }
  sL = L[n];
  reverse(a + 1, a + m + 1);
  for (int 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;
  }
  int l = 1, r = m, an = -1;
  re = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (sol(mid))
      an = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d %d\n", an, re);
  return 0;
}