#include <bits/stdc++.h>
using namespace std;
int main() {
  long n = 0, m = 0;
  cin >> n;
  vector<int> hit(n, -1);
  map<int, pair<int, int> > circle;
  for (int i = 0; i < n; i++) {
    int c, r;
    cin >> c >> r;
    circle.insert(make_pair(c, make_pair(r, i)));
  }
  int hits = 0;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    map<int, pair<int, int> >::iterator it = circle.upper_bound(x);
    for (int j = 0; j < 2; j++) {
      if (it == circle.end()) it--;
      int c = it->first, r = it->second.first, n = it->second.second;
      if ((x - c) * (x - c) + y * y <= r * r) {
        if (hit[n] < 0) {
          hits++;
          hit[n] = i + 1;
        }
      }
      if (it == circle.begin()) {
        break;
      }
      --it;
    }
  }
  cout << hits << endl;
  for (int i = 0; i < hit.size(); i++) {
    cout << hit[i] << " ";
  }
  return 0;
}
