#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct zorc {
int a, b, index;
bool operator < (const zorc z) const {
return (a > z.a) || (a == z.a && b > z.b);
}
}Zorcs[N];
struct axe {
int w, c, index;
bool operator <(const axe a) const {
return (w < a.w) || (w == a.w && c < a.c) || (w == a.w && c == a.c && index < a.index);
}
}Axe[N];
int n, m;
int bs(int key) {
int s = 0, e = m - 1, ans = -1;
while(s <= e) {
int mid = (s + e) / 2;
if (Axe[mid].w >= key) {
ans = mid;
e = mid - 1;
} else
s = mid + 1;
}
return ans;
}
int ans[N];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
zorc z;
scanf("%d %d", &z.a, &z.b);
z.index = i + 1;
Zorcs[i] = z;
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
axe a;
scanf("%d %d", &a.w, &a.c);
a.index = i + 1;
Axe[i] = a;
}
if (m < n){
puts("-1");
return 0;
}
sort(Zorcs, Zorcs + n);
sort(Axe, Axe + m);
set <axe> st;
int soFar = m;
for (int i = 0; i < n; i++) {
int idx = bs(Zorcs[i].a);
if (idx == -1) {
puts("-1");
return 0;
}
for (int j = idx; j < soFar; j++) {
axe a = {Axe[j].c, Axe[j].w, Axe[j].index};
st.insert(a);
}
soFar = idx;
auto A = st.lower_bound({Zorcs[i].b, 0, 0});
if (A == st.end()){
puts("-1");
return 0;
}
st.erase(A);
ans[Zorcs[i].index] = A->index;
}
for (int i = 1; i <= n; i++)
printf("%d ", ans[i]);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gMjAwMDA1OwpzdHJ1Y3Qgem9yYyB7CglpbnQgYSwgYiwgaW5kZXg7Cglib29sIG9wZXJhdG9yIDwgKGNvbnN0IHpvcmMgeikgY29uc3QgewoJCXJldHVybiAoYSA+IHouYSkgfHwgKGEgPT0gei5hICYmIGIgPiB6LmIpOwoJfQp9Wm9yY3NbTl07CnN0c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