# CF - gym - Samara University ACM ICPC 2016-2017 Quarterfinal Qualification Contest --- G

## 代码：

#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> Pair;
const int MAXN = 2e5 + 10;

struct node {
int x, y, id;
bool operator < (const node &c) const {
return x < c.x;
}
}a[MAXN], b[MAXN];

multiset <int> st;
multiset <int> :: iterator it;
map <int, queue <int> > mp;
int ans[MAXN];

int main() {
//freopen("in", "r", stdin);
int n, m;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d", &a[i].x, &a[i].y);
a[i].id = i;
}
scanf("%d", &m);
for (int i = 1; i <= m; i++) {
scanf("%d%d", &b[i].x, &b[i].y);
b[i].id = i;
}
sort (a + 1, a + 1 + n);
sort (b + 1, b + 1 + m);
int cnt = 0;
for (int i = 1, j = 1; i <= m; i++) {
for (; j <= n && b[i].x >= a[j].x; j++) {
st.insert(a[j].y);
mp[a[j].y].push(a[j].id);
}
if (st.empty()) continue;
it = st.upper_bound(b[i].y);
if (it == st.begin()) continue;
if (*--it <= b[i].y) {
int id = mp[*it].front(); mp[*it].pop();
ans[id] = b[i].id;
st.erase(it);
++cnt;
}
}
if (cnt != n) {
puts("-1");
return 0;
}
//printf("%d\n", cnt);
for (int i = 1; i <= n; i++)
printf("%d%c", ans[i], i == n ? '\n' : ' ');
return 0;
}