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.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = acos((long double)-1);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
int pct(int x) { return __builtin_popcount(x); }
namespace input {
template <class T>
void re(complex<T>& x);
template <class T1, class T2>
void re(pair<T1, T2>& p);
template <class T>
void re(vector<T>& a);
template <class T, size_t SZ>
void re(array<T, SZ>& a);
template <class T>
void re(T& x) {
  cin >> x;
}
void re(double& x) {
  string t;
  re(t);
  x = stod(t);
}
void re(long double& x) {
  string t;
  re(t);
  x = stold(t);
}
template <class T, class... Ts>
void re(T& t, Ts&... ts) {
  re(t);
  re(ts...);
}
template <class T>
void re(complex<T>& x) {
  T a, b;
  re(a, b);
  x = {a, b};
}
template <class T1, class T2>
void re(pair<T1, T2>& p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T>& a) {
  for (int i = (0); i < ((int)a.size()); ++i) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ>& a) {
  for (int i = (0); i < (SZ); ++i) re(a[i]);
}
}  // namespace input
using namespace input;
namespace output {
void pr(int x) { cout << x; }
void pr(long x) { cout << x; }
void pr(long long x) { cout << x; }
void pr(unsigned x) { cout << x; }
void pr(unsigned long x) { cout << x; }
void pr(unsigned long long x) { cout << x; }
void pr(float x) { cout << x; }
void pr(double x) { cout << x; }
void pr(long double x) { cout << x; }
void pr(char x) { cout << x; }
void pr(const char* x) { cout << x; }
void pr(const string& x) { cout << x; }
void pr(bool x) { pr(x ? "true" : "false"); }
template <class T>
void pr(const complex<T>& x) {
  cout << x;
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x);
template <class T>
void pr(const T& x);
template <class T, class... Ts>
void pr(const T& t, const Ts&... ts) {
  pr(t);
  pr(ts...);
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T>
void pr(const T& x) {
  pr("{");
  bool fst = 1;
  for (const auto& a : x) pr(!fst ? ", " : "", a), fst = 0;
  pr("}");
}
void ps() { pr("\n"); }
template <class T, class... Ts>
void ps(const T& t, const Ts&... ts) {
  pr(t);
  if (sizeof...(ts)) pr(" ");
  ps(ts...);
}
void pc() { pr("]\n"); }
template <class T, class... Ts>
void pc(const T& t, const Ts&... ts) {
  pr(t);
  if (sizeof...(ts)) pr(", ");
  pc(ts...);
}
}  // namespace output
using namespace output;
namespace io {
void setIn(string second) { freopen(second.c_str(), "r", stdin); }
void setOut(string second) { freopen(second.c_str(), "w", stdout); }
void setIO(string second = "") {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if ((int)second.size()) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
}  // namespace io
using namespace io;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
int n, m;
long long t;
vector<int> ques;
vector<pair<int, int> > Q, scores;
long long sum(vector<int> v) {
  long long res = 0;
  for (auto& t : v) res += t;
  return res;
}
vector<int> eval(int mid) {
  vector<int> cur;
  for (auto& t : Q) cur.push_back(min(max(t.first, mid), t.second));
  return cur;
}
void bad() {
  ps(-1, -1);
  exit(0);
}
void genQues() {
  int lo = 0, hi = m;
  if (sum(eval(lo)) > t || sum(eval(hi)) < t) bad();
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (sum(eval(mid)) >= t)
      hi = mid;
    else
      lo = mid + 1;
  }
  vector<int> cur = eval(lo);
  long long csum = sum(cur);
  for (int i = (0); i < ((int)Q.size()); ++i)
    if (cur[i] == lo && lo > Q[i].first && csum > t) {
      cur[i]--;
      csum--;
    }
  assert(csum == t);
  ques = cur;
  sort(begin(ques), end(ques));
}
void init() {
  setIO();
  re(n, m);
  Q.resize(n);
  re(Q);
  int q;
  re(q);
  scores.resize(q);
  re(scores);
  scores.push_back({m + 1, 0});
  sort(begin(scores), end(scores));
  re(t);
  genQues();
}
long long cdiv(long long a, long long b) { return (a + b - 1) / b; }
bool check(vector<int> rec) {
  assert((int)rec.size() == m + 1);
  assert(sum(rec) == t);
  for (int i = (2); i < (m + 1); ++i) assert(rec[i] <= rec[i - 1]);
  long long a = 0, b = 0;
  int ind = 0;
  for (int i = (1); i < (m + 1); ++i) {
    a += rec[i];
    while (ind < n && ques[ind] <= i) b += ques[ind++];
    if (a > b + (long long)(n - ind) * i) return 0;
  }
  assert(a == b);
  return 1;
}
bool ok(int mid) {
  for (auto& t : scores)
    if (t.first <= mid && t.second != scores[0].second) return 0;
  vector<int> rec = {0};
  int lst = scores[0].second, pos = 0;
  for (int i = (1); i < (m + 1); ++i) {
    if (pos < (int)scores.size() && scores[pos].first == i)
      lst = scores[pos++].second;
    rec.push_back(lst);
  }
  long long csum = sum(rec);
  assert(csum >= t);
  int pre = mid;
  for (auto& u : scores)
    if (u.first > pre) {
      long long dif = rec[u.first - 1] - u.second;
      long long maxDec = dif * (u.first - 1 - pre);
      ckmin(maxDec, csum - t);
      for (int j = (pre + 1); j < (u.first); ++j) {
        long long amt = min(dif, maxDec / (u.first - j));
        rec[j] -= amt;
        maxDec -= amt;
        csum -= amt;
      }
      pre = u.first;
    }
  if (csum != t) return 0;
  return check(rec);
}
long long getMax() {
  if (!(int)scores.size()) return 0;
  int lst = scores[0].second, pos = 0;
  long long ret = 0;
  for (int i = (1); i < (m + 1); ++i) {
    if (pos < (int)scores.size() && scores[pos].first == i) {
      lst = scores[pos++].second;
    }
    ret += lst;
  }
  return ret;
}
int solve() {
  if (!ok(scores[0].first)) return -1;
  int lo = scores[0].first, hi = m;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (ok(mid))
      lo = mid;
    else
      hi = mid - 1;
  }
  return lo;
}
int maxPosi(long long need) {
  if (need > n) return -1;
  scores.insert(begin(scores), {1, need});
  int x = solve();
  scores.erase(begin(scores));
  return x;
}
int main() {
  init();
  long long dif = t - getMax();
  if (dif > 0) {
    int fst = scores[0].first - 1;
    if (fst == 0) bad();
    long long need = cdiv(dif, fst) + scores[0].second;
    int x = maxPosi(need);
    if (x == -1) bad();
    int lo = need, hi = n;
    while (lo < hi) {
      long long mid = (lo + hi + 1) / 2;
      if (maxPosi(mid) == x)
        lo = mid;
      else
        hi = mid - 1;
    }
    ps(x, lo);
  } else {
    int x = solve();
    if (x == -1) bad();
    ps(x, scores[0].second);
  }
}
