#include <bits/stdc++.h>
using namespace std;
const int lim = 1e6;
struct node {
  int x, y, z;
} a[lim], b[lim];
int ans[lim], pre[lim];
int sqr(int x) { return x * x; }
bool dis(int a, int r, int x, int y) { return (sqr(a - x) + sqr(y) <= sqr(r)); }
bool cmp(node a, node b) { return a.x < b.x; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    a[i].z = i;
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &b[i].x, &b[i].y);
    b[i].z = i + 1;
  }
  sort(a, a + n, cmp);
  sort(b, b + m, cmp);
  for (int i = 0; i < m; i++) {
    if (i > 0 && b[i].x == b[i - 1].x)
      pre[i] = pre[i - 1];
    else
      pre[i] = i;
  }
  for (int i = 0; i < n; i++) ans[i] = -1;
  int tot = 0;
  int j = 0;
  for (int i = 0; i < n; i++) {
    while (j < m && b[j].x < a[i].x - a[i].y) j++;
    while (j < m && b[j].x <= a[i].x + a[i].y) {
      if (dis(a[i].x, a[i].y, b[j].x, b[j].y)) {
        if (ans[a[i].z] == -1 || b[j].z < ans[a[i].z]) {
          if (ans[a[i].z] == -1) tot++;
          ans[a[i].z] = b[j].z;
        }
      }
      j++;
    }
    if (j > 0 && i + 1 < n && a[i + 1].x >= b[j - 1].x) j = pre[--j];
  }
  printf("%d\n", tot);
  for (int i = 0; i < n - 1; i++) printf("%d ", ans[i]);
  printf("%d\n", ans[n - 1]);
}
