#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
class node {
 public:
  int x, r, i;
};
int shoot[10009];
node all[10009];
int n, m;
bool cmp(const node &a, const node &b) { return a.x < b.x; }
long long sq(long long a) { return a * a; }
long long dist(int x1, int y1, int x2, int y2) {
  return sq(x1 - x2) + sq(y2 - y1);
}
void check(int pos, int x, int y, int f) {
  if (pos >= n || pos < 0) return;
  long long r = all[pos].r;
  r *= r;
  if (dist(x, y, all[pos].x, 0) <= r) {
    if (shoot[all[pos].i] == -1 || shoot[all[pos].i] > f) shoot[all[pos].i] = f;
  }
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &all[i].x, &all[i].r);
    all[i].i = i;
  }
  sort(all, all + n, cmp);
  memset(shoot, -1, sizeof(shoot));
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    node t;
    t.x = x;
    int pos = lower_bound(all, all + n, t, cmp) - all;
    check(pos, x, y, i);
    check(pos - 1, x, y, i);
  }
  int cnt = 0;
  for (i = 0; i < n; i++)
    if (shoot[i] != -1) cnt++;
  printf("%d\n", cnt);
  for (i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    if (shoot[i] == -1)
      printf("-1");
    else
      printf("%d", shoot[i] + 1);
  }
  printf("\n");
  return 0;
}
