#include <bits/stdc++.h>
using namespace std;
struct circle {
  int id;
  int x, r;
  bool operator<(const circle b) const { return x < b.x; }
} cir[10010];
struct node {
  int x, y;
  int id;
  bool operator<(const node b) const { return x < b.x; }
} p[200010];
int n, m;
int ans[10100];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &cir[i].x, &cir[i].r);
    cir[i].id = i + 1;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
    p[i].id = i + 1;
  }
  sort(cir, cir + n);
  sort(p, p + m);
  for (int i = 1; i <= n; i++) ans[i] = m + m;
  int l, r;
  l = 0;
  r = 0;
  while (r < m) {
    if (p[r].x > cir[l].x + cir[l].r) {
      if (l < n - 1)
        l++;
      else
        break;
    } else if (p[r].x < cir[l].x - cir[l].r)
      r++;
    else {
      if (p[r].y * p[r].y + (p[r].x - cir[l].x) * (p[r].x - cir[l].x) <=
          cir[l].r * cir[l].r) {
        if (p[r].id < ans[cir[l].id]) ans[cir[l].id] = p[r].id;
      }
      if (l < n - 1) {
        if (p[r].y == 0 && p[r].x == cir[l + 1].x - cir[l + 1].r) {
          if (ans[cir[l + 1].id] > p[r].id) ans[cir[l + 1].id] = p[r].id;
        }
      }
      r++;
    }
  }
  int s = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i] != m + m) s++;
  cout << s << endl;
  for (int i = 1; i <= n; i++) {
    if (ans[i] == m + m)
      printf("-1 ");
    else
      printf("%d ", ans[i]);
  }
  puts("");
  return 0;
}
