#include <bits/stdc++.h>
using namespace std;
struct bg {
  long long x, r;
  int cs;
};
const int nm = 10010;
int n;
bg a[nm];
int res[nm];
int m;
int cnt;
bool cmp(bg a, bg b) { return a.x < b.x; }
void xuli(int i, long long x, long long y) {
  int l = 1, r = n, kq = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (x >= a[mid].x + a[mid].r) {
      kq = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  if (kq > 0 && (x - a[kq].x) * (x - a[kq].x) + y * y <= a[kq].r * a[kq].r) {
    if (res[a[kq].cs] == -1) {
      res[a[kq].cs] = i;
      cnt++;
    }
  }
  if (kq < n && (x - a[kq + 1].x) * (x - a[kq + 1].x) + y * y <=
                    a[kq + 1].r * a[kq + 1].r) {
    if (res[a[kq + 1].cs] == -1) {
      res[a[kq + 1].cs] = i;
      cnt++;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d%I64d", &a[i].x, &a[i].r);
    a[i].cs = i;
  }
  sort(a + 1, a + n + 1, cmp);
  scanf("%d", &m);
  memset(res, -1, sizeof(res));
  cnt = 0;
  for (int i = 1; i <= m; ++i) {
    long long x, y;
    scanf("%I64d%I64d", &x, &y);
    xuli(i, x, y);
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; ++i) printf("%d ", res[i]);
}
