403392: GYM101149 G Of Zorcs and Axes

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Of Zorcs and Axestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Zorcs don't like other species. Zorcs like massive curve axes. Right now each of them is going to choose a suitable axe and show beings of other races entrenched nearby that they are not ready to peaceful cultural assimilation. There are n zorcs and m axes in total, and the i-th zorc wants to take an axe with the weight not less than ai and the curvature not less than bi, while the j-th axe has the weight wj and the curvature cj. Zorcs don't like programming problems. Zorcs like massive curve axes. So it's your task to determine which zorc must choose which axe.

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of zorcs.

Each of the next n lines contains two space-separated integers: ai and bi (1 ≤ ai, bi ≤ 109) — the minimal weight and curvature of the axe that suits the i-th zorc.

The next line contains a single integer m (1 ≤ m ≤ 2·105) — the number of axes.

Each of the next m lines contains two space-separated integers: wj and cj (1 ≤ wj, cj ≤ 109) — the weight and the curvature of the j-th axe.

Output

Output n integers, the i-th of which must be the number of axe that should be given to the i-th zorc to fulfill all his requirements. Of course, the same axe can't be given to two different zorcs.

If there is no possibility to distribute axes, fulfilling all requirements of all zorcs, output a single number  - 1 instead of that.

ExamplesInput
3
3 4
5 1
2 6
4
5 7
4 5
3 3
5 2
Output
2 4 1
Input
2
2 5
4 3
2
5 6
3 4
Output
-1

加入题单

算法标签: