#P1305H. Kuroni the Private Tutor

Kuroni the Private Tutor

Description

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 nn questions, and mm students have taken the exam. Each question was worth 11 point. Question ii was solved by at least lil_i and at most rir_i students. Additionally, you know that the total score of all students is tt.

Furthermore, you took a glance at the final ranklist of the quiz. The students were ranked from 11 to mm, where rank 11 has the highest score and rank mm has the lowest score. Ties were broken arbitrarily.

You know that the student at rank pip_i had a score of sis_i for 1iq1 \le i \le 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 11, and the maximum possible score for rank 11 achieving this maximum number of students.

The first line of input contains two integers (1n,m1051 \le n, m \le 10^{5}), denoting the number of questions of the exam and the number of students respectively.

The next nn lines contain two integers each, with the ii-th line containing lil_{i} and rir_{i} (0lirim0 \le l_{i} \le r_{i} \le m).

The next line contains a single integer qq (0qm0 \le q \le m).

The next qq lines contain two integers each, denoting pip_{i} and sis_{i} (1pim1 \le p_{i} \le m, 0sin0 \le s_{i} \le n). It is guaranteed that all pip_{i} are distinct and if pipjp_{i} \le p_{j}, then sisjs_{i} \ge s_{j}.

The last line contains a single integer tt (0tnm0 \le t \le nm), denoting the total score of all students.

Output two integers: the maximum number of students who could have gotten as many points as the student with rank 11, and the maximum possible score for rank 11 achieving this maximum number of students. If there is no valid arrangement that fits the given data, output 1-1 1-1.

Input

The first line of input contains two integers (1n,m1051 \le n, m \le 10^{5}), denoting the number of questions of the exam and the number of students respectively.

The next nn lines contain two integers each, with the ii-th line containing lil_{i} and rir_{i} (0lirim0 \le l_{i} \le r_{i} \le m).

The next line contains a single integer qq (0qm0 \le q \le m).

The next qq lines contain two integers each, denoting pip_{i} and sis_{i} (1pim1 \le p_{i} \le m, 0sin0 \le s_{i} \le n). It is guaranteed that all pip_{i} are distinct and if pipjp_{i} \le p_{j}, then sisjs_{i} \ge s_{j}.

The last line contains a single integer tt (0tnm0 \le t \le 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 11, and the maximum possible score for rank 11 achieving this maximum number of students. If there is no valid arrangement that fits the given data, output 1-1 1-1.

Sample Input 1

5 4
2 4
2 3
1 1
0 1
0 0
1
4 1
7

Sample Output 1

3 2

Sample Input 2

5 6
0 6
0 6
2 5
6 6
4 6
1
3 3
30

Sample Output 2

-1 -1

Note

For the first sample, here is one possible arrangement that fits the data:

Students 11 and 22 both solved problems 11 and 22.

Student 33 solved problems 22 and 33.

Student 44 solved problem 44.

The total score of all students is T=7T = 7. Note that the scores of the students are 22, 22, 22 and 11 respectively, which satisfies the condition that the student at rank 44 gets exactly 11 point. Finally, 33 students tied for first with a maximum score of 22, and it can be proven that we cannot do better with any other arrangement.