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;
using i64 = long long;
const int maxN = 111111;
int l, r, q;
int cnt[maxN], la[maxN], ra[maxN], Lb[maxN], Rb[maxN];
int va[maxN], vb[maxN];
i64 t, xL, xR;
array<i64, 2> lb[maxN], rb[maxN];
vector<array<i64, 2> > cond;
array<i64, 2> operator+(const array<i64, 2> &a, const array<i64, 2> &b) {
  return {a[0] + b[0], a[1] + b[1]};
}
array<i64, 2> operator-(const array<i64, 2> &a, const array<i64, 2> &b) {
  return {a[0] - b[0], a[1] - b[1]};
}
void solve(vector<int> a, vector<array<i64, 2> > b, array<i64, 2> add) {
  i64 ls = 0;
  array<i64, 2> rs = add;
  int lc = l;
  for (int i = 0; i < r; i++) rs = rs + b[i];
  for (int i = 0; i <= r; i++) cnt[i] = 0;
  for (auto x : a) cnt[x]++;
  for (int i = 0; i <= r; i++) {
    cond.push_back(array<i64, 2>{0ll, ls} + rs);
    rs = rs - b[i];
    lc -= cnt[i];
    ls += lc;
  }
}
i64 ceild(i64 x, i64 y) {
  if (x % y == 0 || x < 0) return x / y;
  return x / y + 1;
}
i64 floord(i64 x, i64 y) {
  if (x % y == 0 || x > 0) return x / y;
  return x / y - 1;
}
bool check(int p, int v = -1) {
  i64 ls = 0;
  array<i64, 2> rs{0, 0};
  xL = 0;
  xR = l;
  if (v == -1) {
    for (int i = 0; i < r; i++) {
      rb[i] = {0, Rb[i]};
      lb[i] = {0, Lb[i]};
      if (i < p) {
        lb[i] = {1, 0};
        rb[i] = {1, 0};
      }
    }
  } else {
    for (int i = 0; i < r; i++) {
      rb[i] = {0, min(Rb[i], v)};
      lb[i] = {0, Lb[i]};
    }
    xR = v;
  }
  for (int i = 0; i < p; i++) {
    xL = max(xL, (i64)Lb[i]);
    xR = min(xR, (i64)Rb[i]);
  }
  for (int i = 0; i < l; i++) ls += la[i];
  for (int i = 0; i < r; i++) rs = rs + lb[i];
  if (ls > t) return 0;
  if (rs[0] > 0)
    xR = min(xR, floord(t - rs[1], rs[0]));
  else {
    if (rs[1] > t) return 0;
  }
  cond.clear();
  solve(vector<int>(ra, ra + l), vector<array<i64, 2> >(rb, rb + r), {0, 0});
  solve(vector<int>(la, la + l), vector<array<i64, 2> >(rb, rb + r),
        array<i64, 2>{0, t} - array<i64, 2>{0, ls});
  solve(vector<int>(ra, ra + l), vector<array<i64, 2> >(lb, lb + r),
        array<i64, 2>{0, t} - rs);
  solve(vector<int>(la, la + l), vector<array<i64, 2> >(lb, lb + r),
        array<i64, 2>{0, 2 * t} - array<i64, 2>{0, ls} - rs);
  for (auto y : cond) {
    if (y[0] == 0) {
      if (y[1] < t) return 0;
    } else if (y[0] > 0) {
      xL = max(xL, ceild(t - y[1], y[0]));
    } else {
      xR = min(xR, floord(y[1] - t, -y[0]));
    }
  }
  if (xL > xR) return 0;
  if (v == -1)
    return check(p, xR);
  else
    return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> l >> r;
  for (int i = 0; i < l; i++) {
    cin >> la[i] >> ra[i];
  }
  cin >> q;
  for (int i = 0; i < r; i++) {
    Lb[i] = 0;
    Rb[i] = l;
  }
  for (int i = 0; i < q; i++) {
    int rank, score;
    cin >> rank >> score;
    --rank;
    Lb[rank] = score;
    Rb[rank] = score;
  }
  for (int i = 1; i < r; i++) {
    Rb[i] = min(Rb[i], Rb[i - 1]);
  }
  for (int i = r - 2; i >= 0; i--) {
    Lb[i] = max(Lb[i], Lb[i + 1]);
  }
  cin >> t;
  if (!check(1)) {
    cout << "-1 -1\n";
    return 0;
  }
  int peoL = 1, peoR = r + 1;
  while (peoL + 1 < peoR) {
    int mid = (peoL + peoR) >> 1;
    if (check(mid))
      peoL = mid;
    else
      peoR = mid;
  }
  check(peoL);
  cout << peoL << " " << xR << "\n";
}