#include <bits/stdc++.h>
using namespace std;
const int N = 10001;
struct node {
  int x, r, id;
  bool operator<(const node &t) const { return x < t.x; }
} tar[N];
int fir_hit[N];
int main() {
  int n, k, i, l, r, m, x, y, a, b, cnt;
  memset(fir_hit, -1, sizeof fir_hit);
  while (scanf("%d", &n) == 1) {
    for (i = 1; i <= n; i++) scanf("%d%d", &tar[i].x, &tar[i].r), tar[i].id = i;
    sort(tar + 1, tar + n + 1);
    scanf("%d", &k);
    cnt = 0;
    for (i = 1; i <= k; i++) {
      scanf("%d%d", &x, &y);
      l = 1, r = n;
      while (l <= r) {
        m = l + r >> 1;
        a = (tar[m].x - x) * (tar[m].x - x) + y * y;
        b = tar[m].r * tar[m].r;
        if (a > b) {
          if (x < tar[m].x)
            r = m - 1;
          else
            l = m + 1;
        } else
          break;
      }
      if (l <= r) {
        if (fir_hit[tar[m].id] == -1) fir_hit[tar[m].id] = i, cnt++;
        if (a == b && !y) {
          if (m > 1) {
            if (tar[m - 1].x + tar[m - 1].r == x)
              if (fir_hit[tar[m - 1].id] == -1)
                fir_hit[tar[m - 1].id] = i, cnt++;
          }
          if (m < n) {
            if (tar[m + 1].x - tar[m + 1].r == x)
              if (fir_hit[tar[m + 1].id] == -1)
                fir_hit[tar[m + 1].id] = i, cnt++;
          }
        }
      }
    }
    printf("%d\n", cnt);
    for (i = 1; i < n; i++) printf("%d ", fir_hit[i]), fir_hit[i] = -1;
    printf("%d\n", fir_hit[n]), fir_hit[n] = -1;
  }
  return 0;
}
