#include <bits/stdc++.h>
using namespace std;
struct node {
  double x, r;
  int f, id;
} a[100005];
bool cmp1(node a, node b) { return a.x < b.x; }
bool cmp2(node a, node b) { return a.id < b.id; }
int isin(int i, double x, double y) {
  double t = (x - a[i].x) * (x - a[i].x) + y * y;
  if (t <= a[i].r * a[i].r) return 1;
  return 0;
}
int main() {
  int n, i, m;
  double x, y;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf%lf", &a[i].x, &a[i].r);
    a[i].f = -1;
    a[i].id = i;
  }
  sort(a, a + n, cmp1);
  scanf("%d", &m);
  int ans = 0;
  for (i = 1; i <= m; i++) {
    scanf("%lf%lf", &x, &y);
    int l = 0, r = n - 1, mid;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (isin(mid, x, y)) {
        if (a[mid].f == -1) {
          a[mid].f = i;
          ans++;
        }
        break;
      }
      if (x > a[mid].x)
        l = mid + 1;
      else
        r = mid - 1;
    }
    l = mid;
    if (l + 1 < n && isin(l + 1, x, y)) {
      if (a[l + 1].f == -1) {
        a[l + 1].f = i;
        ans++;
      }
    }
    if (l - 1 >= 0 && isin(l - 1, x, y)) {
      if (a[l - 1].f == -1) {
        a[l - 1].f = i;
        ans++;
      }
    }
  }
  sort(a, a + n, cmp2);
  printf("%d\n", ans);
  for (i = 0; i < n - 1; i++) printf("%d ", a[i].f);
  printf("%d\n", a[n - 1].f);
  return 0;
}
