#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1000001;
struct Circle {
  int x;
  int r;
  int f;
} cir[MaxN];
int s[MaxN];
bool cmp(int x, int y) { return cir[x].x < cir[y].x; }
bool in(int x, int y, int xx, int r) {
  x -= xx;
  return x * x + y * y <= r * r;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int i;
    int j;
    for (i = 0; i < n; i++) {
      scanf("%d%d", &cir[i].x, &cir[i].r);
      cir[i].f = -1;
      s[i] = i;
    }
    sort(s, s + n, cmp);
    int m;
    scanf("%d", &m);
    int x, y;
    int l, r;
    int cnt = 0;
    for (i = 0; i < m; i++) {
      scanf("%d%d", &x, &y);
      if (x >= cir[s[0]].x - cir[s[0]].r &&
          x <= cir[s[n - 1]].x + cir[s[n - 1]].r) {
        l = 0;
        r = n - 1;
        int mid;
        while (l <= r) {
          mid = (l + r) >> 1;
          if (x < cir[s[mid]].x - cir[s[mid]].r) {
            r = mid - 1;
          } else if (x > cir[s[mid]].x + cir[s[mid]].r) {
            l = mid + 1;
          } else {
            break;
          }
        }
        if (cir[s[mid]].f == -1 && in(x, y, cir[s[mid]].x, cir[s[mid]].r)) {
          cir[s[mid]].f = i + 1;
          cnt++;
        }
        if (0 == y) {
          if (mid < n - 1 && cir[s[mid + 1]].x - cir[s[mid + 1]].r == x &&
              cir[s[mid + 1]].f == -1) {
            cir[s[mid + 1]].f = i + 1;
            cnt++;
          }
          if (mid > 0 && cir[s[mid - 1]].x + cir[s[mid - 1]].r == x &&
              cir[s[mid - 1]].f == -1) {
            cir[s[mid - 1]].f = i + 1;
            cnt++;
          }
        }
      }
    }
    printf("%d\n", cnt);
    for (i = 0; i < n - 1; i++) {
      printf("%d ", cir[i].f);
    }
    printf("%d\n", cir[i].f);
  }
  return 0;
}
