#include <bits/stdc++.h>
using namespace std;
struct Circle {
  int x;
  int r;
  bool hit;
  int pos;
} V[10001];
bool cmp(Circle A, Circle B) { return A.x < B.x; }
int res[10001];
int main() {
  int N;
  while (scanf("%d", &N) != EOF) {
    for (int i = 0; i < N; i++) {
      scanf("%d %d", &V[i].x, &V[i].r);
      V[i].hit = false;
      V[i].pos = i;
    }
    memset(res, -1, sizeof(res));
    sort(V, V + N, cmp);
    int cnt = 0;
    int M;
    scanf("%d", &M);
    for (int i = 1; i <= M; i++) {
      int x, y;
      scanf("%d %d", &x, &y);
      Circle C;
      C.x = x;
      int k = lower_bound(V, V + N, C, cmp) - V;
      if (V[k].hit == false &&
          (V[k].x - x) * (V[k].x - x) + y * y <= V[k].r * V[k].r) {
        cnt++;
        V[k].hit = true;
        res[V[k].pos] = i;
      }
      if (k >= 1) {
        k--;
        if (V[k].hit == false &&
            (V[k].x - x) * (V[k].x - x) + y * y <= V[k].r * V[k].r) {
          cnt++;
          V[k].hit = true;
          res[V[k].pos] = i;
        }
      }
    }
    cout << cnt << endl;
    for (int i = 0; i < N; i++) {
      if (i) cout << " ";
      cout << res[i];
    }
    cout << endl;
  }
  return 0;
}
