#include <bits/stdc++.h>
using namespace std;
struct circle {
  int st, dr, cul, id, r, y, x;
} C[300005];
int CU[300005];
int cmp(circle a, circle b) {
  return tie(a.st, a.dr, a.id) < tie(b.st, b.dr, b.id);
}
pair<int, int> G[300005];
int n, m, a, b;
int ok(int shot, int circ) {
  return (C[circ].r * C[circ].r >=
          G[shot].second * G[shot].second +
              (G[shot].first - C[circ].x) * (G[shot].first - C[circ].x));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &(C[i].x), &(C[i].r));
    C[i].st = (C[i].x) - (C[i].r);
    C[i].dr = (C[i].x) + (C[i].r);
    C[i].cul = -1;
    C[i].id = i;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d %d", &(G[i].first), &(G[i].second));
  sort(C + 1, C + n + 1, cmp);
  int st, dr, mij;
  for (int i = m; i >= 1; i--) {
    st = 1;
    dr = n;
    while (st < dr) {
      mij = (st + dr) / 2;
      if (C[mij].dr < G[i].first)
        st = mij + 1;
      else if (C[mij].st > G[i].first)
        dr = mij - 1;
      else
        st = dr = mij;
    }
    for (int el = st + 1; el >= st - 1; el--)
      if (ok(i, el)) CU[C[el].id] = i;
  }
  int nhit = n;
  for (int i = 1; i <= n; i++)
    if (!CU[i]) {
      nhit--;
      CU[i] = -1;
    }
  printf("%d\n", nhit);
  for (int i = 1; i <= n; i++) printf("%d ", CU[i]);
}
