#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, r, idx, shot;
  node() {}
  node(int a, int b, int c, int d) { x = a, r = b, idx = c, shot = d; }
} a[10010];
int n, m, cnt;
bool by_x(node a, node b) { return a.x < b.x; }
bool by_idx(node a, node b) { return a.idx < b.idx; }
int bsearch(int x) {
  int l = -1, r = n, best = 0;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (a[mid].x <= x) {
      l = mid, best = mid;
    } else {
      r = mid - 1;
    }
  }
  return best;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, r;
    scanf("%d%d", &x, &r);
    a[i] = node(x, r, i, -1);
  }
  sort(a, a + n, by_x);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int p = bsearch(x);
    if ((((x - a[p].x) * (x - a[p].x) + y * y) <= a[p].r * a[p].r) &&
        (a[p].shot) == -1) {
      a[p].shot = i;
      cnt++;
    }
    if (p > 0 &&
        (((x - a[p - 1].x) * (x - a[p - 1].x) + y * y) <=
         a[p - 1].r * a[p - 1].r) &&
        (a[p - 1].shot) == -1) {
      a[p - 1].shot = i;
      cnt++;
    }
    if (p < n - 1 &&
        (((x - a[p + 1].x) * (x - a[p + 1].x) + y * y) <=
         a[p + 1].r * a[p + 1].r) &&
        (a[p + 1].shot) == -1) {
      a[p + 1].shot = i;
      cnt++;
    }
  }
  sort(a, a + n, by_idx);
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) printf("%d ", a[i].shot);
  puts("");
  return 0;
}
