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;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
const long long MOD2 = (long long)1000000007 * (long long)1000000007;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
long long L[100035], R[100035], T;
int a[100035];
struct Line {
  long long a, b;
  long long get(long long x) { return a * x + b; }
};
struct ConvexHull {
  int size = 0, preQueryPos = 0;
  vector<Line> hull;
  ConvexHull() { size = 0; }
  void clear() {
    size = 0;
    preQueryPos = 0;
    hull.clear();
  }
  bool is_bad(int curr, int prev, int next) {
    Line c = hull[curr], p = hull[prev], n = hull[next];
    return (c.b - n.b) * (c.a - p.a) <= (p.b - c.b) * (n.a - c.a);
  }
  void add_line(long long a, long long b) {
    hull.push_back((Line){a, b});
    size++;
    while (size > 2 && is_bad(size - 2, size - 3, size - 1)) {
      hull[size - 2] = hull[size - 1];
      size--;
      hull.pop_back();
    }
  }
  long long query(long long x) {
    if (size == 0) return -(1LL << 60);
    int l = -1, r = size - 1;
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (hull[m].get(x) <= hull[m + 1].get(x))
        l = m;
      else
        r = m;
    }
    long double z = hull[r].get(x);
    return z;
  }
  long long queryByOrder(long long x) {
    if (preQueryPos > size - 1)
      preQueryPos = size - 1;
    else {
      while (preQueryPos + 1 < size) {
        if (hull[preQueryPos].get(x) <= hull[preQueryPos + 1].get(x)) {
          preQueryPos++;
        } else
          break;
      }
    }
    return hull[preQueryPos].get(x);
  }
};
long long up[100035];
void cal() {
  ConvexHull ch;
  for (int i = 0; i <= n; i++) {
    ch.add_line(i - n, -R[i]);
  }
  for (int i = m; i; i--) {
    maxtt(up[i], ch.queryByOrder(m - i) + T);
  }
  ch.clear();
  for (int i = 0; i <= n; i++) {
    ch.add_line(i - n, -L[i]);
  }
  for (int i = m; i; i--) {
    maxtt(up[i], ch.queryByOrder(m - i) + L[n]);
  }
}
bool judg(int n) {
  long long s1 = 0, s2 = 0, mn = 0;
  int lst = 0;
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (a[i] != -1) {
      if (mn > a[i]) return 0;
      s1 += a[i];
      s2 += (long long)(a[i] - mn) * (i - lst - 1);
      if (s1 < up[i]) {
        if (s1 + s2 < up[i]) return 0;
        s2 -= up[i] - s1;
        s1 = up[i];
      }
      lst = i;
      mn = a[i];
    } else {
      s1 += mn;
      if (s1 < up[i]) {
        if (s1 + s2 >= up[i]) {
          s2 -= up[i] - s1;
          s1 = up[i];
        } else {
          long long v = up[i] - s1 - s2;
          long long t = (v + i - lst - 1) / (i - lst);
          mn += t;
          s1 = up[i];
          s2 = t * (i - lst) - v;
        }
      }
    }
  return s1 <= T && (a[n] != -1 || s1 + s2 >= T);
}
int wk(int n, int k) {
  long long s1 = 0, s2 = 0, mn = 0;
  int lst = 0;
  for (int(i) = 1; (i) <= (int)(n - k); (i)++)
    if (a[i] != -1) {
      s1 += a[i];
      s2 += (long long)(a[i] - mn) * (i - lst - 1);
      if (s1 < up[i]) {
        s2 -= up[i] - s1;
        s1 = up[i];
      }
      lst = i;
      mn = a[i];
    } else {
      s1 += mn;
      if (s1 < up[i]) {
        if (s1 + s2 >= up[i]) {
          s2 -= up[i] - s1;
          s1 = up[i];
        } else {
          long long v = up[i] - s1 - s2;
          long long t = (v + i - lst - 1) / (i - lst);
          mn += t;
          s1 = up[i];
          s2 = t * (i - lst) - v;
        }
      }
    }
  long long t = -1;
  for (int i = n - k + 1; i <= n; i++)
    if (a[i] != -1) {
      if (t == -1)
        t = a[i];
      else if (t != a[i])
        return -1;
    }
  if (t == -1) t = (T - s1) / k;
  long long v = T - t * k;
  if (s1 > v || mn > t) return -1;
  return s1 + s2 + (t - mn) * (n - k - lst) >= v ? t : -1;
}
void fmain(int tid) {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%lld%lld", L + i, R + i);
  }
  int q;
  scanf("%d", &q);
  memset(a, -1, sizeof a);
  for (int(i) = 1; (i) <= (int)(q); (i)++) {
    int p, s;
    scanf("%d%d", &p, &s);
    a[m + 1 - p] = s;
  }
  scanf("%lld", &T);
  sort(L + 1, L + 1 + n);
  sort(R + 1, R + 1 + n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    L[i] += L[i - 1];
    R[i] += R[i - 1];
  }
  cal();
  if (!judg(m)) {
    puts("-1 -1");
    return;
  }
  int l = 1, r = m + 1;
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    if (wk(m, mid) != -1)
      l = mid;
    else
      r = mid;
  }
  int A = wk(m, l);
  printf("%d %d\n", l, A);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}