403392: GYM101149 G Of Zorcs and Axes
Description
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.
InputThe 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.
OutputOutput 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.
ExamplesInput3Output
3 4
5 1
2 6
4
5 7
4 5
3 3
5 2
2 4 1Input
2Output
2 5
4 3
2
5 6
3 4
-1