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>
namespace my_std {
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
inline T rnd(T l, T r) {
  return uniform_int_distribution<T>(l, r)(rng);
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T &t) {
  t = 0;
  char f = 0, ch = getchar();
  double d = 0.1;
  while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
  while (ch <= '9' && ch >= '0') t = t * 10 + ch - 48, ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t = (f ? -t : t);
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
char __sr[1 << 21], __z[20];
int __C = -1, __zz = 0;
inline void Ot() { fwrite(__sr, 1, __C + 1, stdout), __C = -1; }
inline void print(int x) {
  if (__C > 1 << 20) Ot();
  if (x < 0) __sr[++__C] = '-', x = -x;
  while (__z[++__zz] = x % 10 + 48, x /= 10)
    ;
  while (__sr[++__C] = __z[__zz], --__zz)
    ;
  __sr[++__C] = '\n';
}
void file() {}
inline void chktime() {}
long long ksm(long long x, int y) {
  long long ret = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
}  // namespace my_std
using namespace my_std;
int n, m;
long long T;
long long L[101010], R[101010];
long long preL[101010], preR[101010];
long long pre[101010];
long long _s[101010], s[101010];
int ans1, ans2;
bool check(long long sum, long long *pre1, long long *pre) {
  static int st[101010];
  int tp = 0;
  for (int j = (1); j <= (n); j++) {
    auto Cross = [&](int x1, long long y1, int x2, long long y2) {
      return x1 * y2 - x2 * y1;
    };
    while (tp > 1 && Cross(j - st[tp], pre[j] - pre[st[tp]], j - st[tp - 1],
                           pre[j] - pre[st[tp - 1]]) >= 0)
      --tp;
    st[++tp] = j;
  }
  auto clc = [&](int i, int j) { return pre[j] - 1ll * j * (m - i); };
  for (int i = (0); i <= (m); i++) {
    while (tp > 1 && clc(i, st[tp]) > clc(i, st[tp - 1])) --tp;
    if (pre1[i] + 1ll * n * (m - i) + clc(i, st[tp]) < sum) return 0;
  }
  return 1;
}
bool Check(long long *w) {
  long long _ = 0;
  for (int i = (1); i <= (n); i++) _ += w[i];
  assert(_ == T);
  reverse(w + 1, w + n + 1);
  for (int i = (1); i <= (n); i++) pre[i] = pre[i - 1] + w[i];
  return check(T, preR, pre) && check(preL[m], preL, pre);
}
bool check(int len, int tp = 1) {
  for (int i = (1); i <= (len); i++)
    if (s[i] != -1 && s[i] != _s[1]) return 0;
  static long long w[101010];
  static long long suf[101010];
  for (int i = (1); i <= (n); i++) w[i] = _s[i];
  for (int i = (2); i <= (len); i++) w[i] = w[i - 1];
  for (int i = (n); i >= (1); i--) suf[i] = suf[i + 1] + w[i];
  long long res = T - suf[1];
  if (res < 0) return 0;
  vector<int> V;
  V.push_back(len);
  for (int i = (len + 1); i <= (n + 1); i++)
    if (s[i] != -1) V.push_back(i);
  for (int i = ((int)V.size() - 2); i >= (0); i--) {
    int l = V[i], r = V[i + 1];
    if (l == r - 1) continue;
    long long t = (w[l] - w[r]) * (r - l - 1);
    if (t <= res) {
      for (int j = (l + 1); j <= (r - 1); j++) w[j] = w[l];
      res -= t;
      continue;
    }
    t = r - l - 1;
    long long tt = res / t;
    res %= t;
    if (tt > m) return 0;
    for (int j = (l + 1); j <= (r - 1); j++) w[j] += tt + ((j - l - 1) < res);
    res = 0;
    break;
  }
  if (!res) return Check(w);
  if (tp) {
    for (int i = (1); i <= (len); i++)
      if (s[i] != -1) return 0;
  }
  long long dt = res / (V[1] - 1);
  res %= V[1] - 1;
  if (!res || res >= len) {
    for (int i = (1); i <= (V[1] - 1); i++) w[i] += dt;
    for (int i = (1); i <= (res); i++) ++w[i];
    return Check(w);
  }
  for (int i = (1); i <= (V[1] - 1); i++) w[i] += dt;
  res = len - res;
  for (int i = (0); i <= ((int)V.size() - 2); i++) {
    int l = V[i], r = V[i + 1];
    long long t = (w[l] - w[r]) * (r - l - 1);
    if (t < res) {
      for (int j = (l + 1); j <= (r - 1); j++) w[j] = w[r];
      res -= t;
      continue;
    }
    t = r - l - 1;
    for (int j = (l + 1); j <= (r - 1); j++) w[j] -= res / t;
    res %= t;
    for (int j = (r - 1); j >= (r - res); j--) --w[j];
    res = 0;
    break;
  }
  if (res) return 0;
  for (int i = (1); i <= (len); i++) w[i]++;
  return Check(w);
}
void work1() {
  for (int l = 1, r = n, mid; (mid = (l + r) >> 1, l <= r);)
    if (check(mid))
      ans1 = mid, l = mid + 1;
    else
      r = mid - 1;
}
void work2() {
  if (!ans1) exit(puts("-1 -1") & 0);
  for (int i = (1); i <= (ans1); i++)
    if (s[i] != -1) exit(printf("%d %lld\n", ans1, s[i]) & 0);
  for (int l = _s[1], r = m, mid; (mid = (l + r) >> 1, l <= r);) {
    for (int i = (1); i <= (ans1); i++) _s[i] = mid;
    if (check(ans1, 0))
      ans2 = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d %d\n", ans1, ans2);
}
int main() {
  file();
  read(m, n);
  for (int i = (1); i <= (m); i++) read(L[i], R[i]);
  sort(L + 1, L + m + 1), sort(R + 1, R + m + 1);
  for (int i = (1); i <= (m); i++)
    preL[i] = preL[i - 1] + L[i], preR[i] = preR[i - 1] + R[i];
  for (int i = (1); i <= (n); i++) _s[i] = s[i] = -1;
  int x, y;
  int Q;
  read(Q);
  while (Q--) read(x, y), s[x] = _s[x] = y;
  for (int i = (n); i >= (1); i--) chkmax(_s[i], _s[i + 1]);
  read(T);
  work1(), work2();
  return 0;
}