#include <bits/stdc++.h>
using namespace std;
struct mm {
  int x;
  int r;
  int p;
  int i;
} a[10005];
bool cmp(mm a, mm b) { return a.x < b.x; }
bool cmp1(mm a, mm b) { return a.i < b.i; }
int pr(int x, int y, int x1, int y1) {
  return (x - x1) * (x - x1) + (y - y1) * (y - y1);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].r;
    a[i].p = -1;
    a[i].i = i;
  }
  sort(a + 1, a + n + 1, cmp);
  int m, ans = 0;
  cin >> m;
  for (int j = 1; j <= m; j++) {
    int x1, y1;
    cin >> x1 >> y1;
    int l1 = 1, r1 = n;
    while (l1 < r1) {
      int c = (l1 + r1) / 2;
      if (x1 > a[c].x)
        l1 = c + 1;
      else
        r1 = c;
    }
    if ((pr(x1, y1, a[l1].x, 0) <= (a[l1].r * a[l1].r)) && (a[l1].p == -1)) {
      a[l1].p = j;
      ans++;
    }
    if ((pr(x1, y1, a[l1 + 1].x, 0) <= a[l1 + 1].r * a[l1 + 1].r) &&
        (a[l1 + 1].p == -1)) {
      a[l1 + 1].p = j;
      ans++;
    }
    if ((pr(x1, y1, a[l1 - 1].x, 0) <= a[l1 - 1].r * a[l1 - 1].r) &&
        (a[l1 - 1].p == -1)) {
      a[l1 - 1].p = j;
      ans++;
    }
  }
  sort(a + 1, a + n + 1, cmp1);
  cout << ans << endl;
  for (int i = 1; i <= n; i++) cout << " " << a[i].p;
  return 0;
}
