#include <bits/stdc++.h>
using namespace std;
int n, m, res;
int vis[100005];
struct node {
  int x, r;
  int id;
} a[10005];
bool cmp(node a, node b) { return a.x < b.x; }
int binary(int x) {
  int l, r, mid;
  l = 0, r = n;
  while (l + 1 < r) {
    mid = (l + r) >> 1;
    if (a[mid].x < x)
      l = mid;
    else
      r = mid;
  }
  return r;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].r;
    a[i].id = i;
  }
  sort(a + 1, a + 1 + n, cmp);
  memset(vis, -1, sizeof(vis));
  cin >> m;
  int cnt = 0;
  for (int j = 1; j <= m; j++) {
    int x, y;
    cin >> x >> y;
    int pos = binary(x);
    for (int i = pos - 2; i <= pos + 2; i++) {
      if (i < 1 || i > n) continue;
      if ((x - a[i].x) * (x - a[i].x) + y * y <= a[i].r * a[i].r) {
        if (vis[a[i].id] == -1) {
          cnt++;
          vis[a[i].id] = j;
        }
      }
    }
  }
  cout << cnt << endl;
  for (int i = 1; i <= n; i++) cout << vis[i] << " ";
  return 0;
}
