#include <bits/stdc++.h>
using namespace std;
int n, m, ans, p[100005];
struct Node {
  int x, r, id;
} node[10005];
bool cmp(Node a, Node b) { return a.x < b.x; }
int erfen(int x) {
  int l = 0, r = n, mid;
  while (l + 1 < r) {
    mid = (r + l) >> 1;
    if (node[mid].x < x) {
      l = mid;
    } else
      r = mid;
  }
  return r;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &node[i].x, &node[i].r);
    node[i].id = i;
  }
  memset(p, -1, sizeof(p));
  sort(node + 1, node + n + 1, cmp);
  scanf("%d", &m);
  for (int j = 1; j <= m; j++) {
    int x, y, pos;
    scanf("%d%d", &x, &y);
    pos = erfen(x);
    for (int i = pos - 2; i <= pos + 2; i++) {
      if (i < 1 || i > n) continue;
      if ((x - node[i].x) * (x - node[i].x) + y * y <= node[i].r * node[i].r) {
        if (p[node[i].id] == -1) {
          ans++;
          p[node[i].id] = j;
        }
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    printf("%d ", p[i]);
  }
  return 0;
}
