#include <bits/stdc++.h>
using namespace std;
const int N = 10010, D = 20000;
int n, m, x, y, z, c[N], r[N], s[N];
vector<int> v[D * 2 + 10];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &c[i], &r[i]);
    c[i] += D;
    s[i] = -1;
    for (int j = c[i] - r[i]; j <= c[i] + r[i]; j++) v[j].push_back(i);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    x += D;
    for (auto j : v[x])
      if (s[j] == -1)
        if (y * y + (x - c[j]) * (x - c[j]) <= r[j] * r[j]) s[j] = i, z++;
  }
  printf("%d\n", z);
  for (int i = 1; i <= n; i++) printf("%d ", s[i]);
  return 0;
}
