#include <bits/stdc++.h>
using namespace std;
struct pt {
  int x;
  int r;
  int k;
};
pt a[10005];
int res[10005];
int pr(pt a, pt b) { return a.x < b.x; }
int ab(int x) { return x >= 0 ? x : -x; }
int i, j, k, n, m, x, y, z, t, l, r, c;
long long dx, dy;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a[i].x, &a[i].r);
    a[i].k = i;
    res[i] = -1;
  }
  sort(a, a + n, pr);
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    l = 0;
    r = n - 1;
    while (l <= r) {
      c = (l + r) / 2;
      if (a[c].x <= x) {
        l = c + 1;
      } else {
        r = c - 1;
      }
    }
    c = l - 1;
    if (c >= 0 && c < n) {
      dx = ab(a[c].x - x);
      dy = ab(y);
      if (dx * dx + dy * dy <= a[c].r * a[c].r) {
        z = a[c].k;
        if (res[z] == -1) {
          res[z] = i + 1;
        }
      }
    }
    c++;
    if (c >= 0 && c < n) {
      dx = ab(a[c].x - x);
      dy = ab(y);
      if (dx * dx + dy * dy <= a[c].r * a[c].r) {
        z = a[c].k;
        if (res[z] == -1) {
          res[z] = i + 1;
        }
      }
    }
  }
  x = 0;
  for (i = 0; i < n; i++) {
    if (res[i] != -1) {
      x++;
    }
  }
  printf("%d\n", x);
  for (i = 0; i < n; i++) {
    printf("%d ", res[i]);
  }
  printf("\n");
  return 0;
}
