#include <bits/stdc++.h>
using namespace std;
struct targ {
  long long x, r;
  int id, s;
} tar[10004];
bool _x(targ a, targ b) { return a.x < b.x; }
bool _id(targ a, targ b) { return a.id < b.id; }
int fd(int l, int r, long long x) {
  if (l == r) return l;
  int m = l + r >> 1;
  if (tar[m].x < x)
    return fd(m + 1, r, x);
  else
    return fd(l, m, x);
}
int cnt = 0;
void sl(int now, int p, long long x, long long y) {
  if ((x - tar[p].x) * (x - tar[p].x) + y * y <= tar[p].r * tar[p].r)
    tar[p].s = now, cnt++;
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &tar[i].x, &tar[i].r);
    tar[i].id = i;
    tar[i].s = -1;
  }
  sort(tar + 1, tar + n + 1, _x);
  scanf("%d", &m);
  long long x, y;
  for (int i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    int p = fd(1, n, x);
    if (tar[p].s == -1) sl(i, p, x, y);
    if (p - 1 && tar[p - 1].s == -1) sl(i, p - 1, x, y);
  }
  sort(tar + 1, tar + n + 1, _id);
  cout << cnt << endl;
  for (int i = 1; i <= n; i++) {
    printf("%d%c", tar[i].s, " \n"[i == n]);
  }
}
