#include <bits/stdc++.h>
using namespace std;
long long n;
long long x[10005], r[10005];
long long id[10005];
long long m, f[10005];
long long res;
bool Less(const long long &a, const long long &b) { return x[a] < x[b]; }
long long sqr(long long a) { return a * a; }
void search(long long lw, long long up, long long tx, long long ty,
            long long ind) {
  if (lw > up) return;
  long long mid = (lw + up) / 2;
  if (sqr(tx - x[id[mid]]) + sqr(ty) <= sqr(r[id[mid]]) && f[id[mid]] == -1) {
    res++;
    f[id[mid]] = ind;
  }
  if (tx < x[id[mid]]) search(lw, mid - 1, tx, ty, ind);
  if (tx > x[id[mid]]) search(mid + 1, up, tx, ty, ind);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x[i] >> r[i];
    id[i] = i;
  }
  sort(id, id + n, Less);
  memset(f, -1, sizeof(f));
  cin >> m;
  for (long long i = 1; i < m + 1; i++) {
    long long tx, ty;
    cin >> tx >> ty;
    search(0, n - 1, tx, ty, i);
  }
  cout << res << endl;
  for (long long i = 0; i < n; i++) cout << f[i] << " ";
  cout << endl;
  return 0;
}
