#include <bits/stdc++.h>
using namespace std;
map<int, int> cirmap;
map<pair<int, int>, int> shotmap;
map<int, int> hitmap;
long long sqr(long long k) { return k * k; }
void solve() {
  cirmap.clear();
  shotmap.clear();
  hitmap.clear();
  int n;
  cin >> n;
  vector<pair<int, int> > circles(n);
  for (int i = 0; i < n; ++i) {
    int xi, ri;
    cin >> xi >> ri;
    circles[i] = pair<int, int>(xi, ri);
    cirmap[xi] = i;
  }
  sort(circles.begin(), circles.end());
  vector<int> right(n);
  for (int i = 0; i < n; ++i) right[i] = circles[i].first + circles[i].second;
  int m;
  cin >> m;
  vector<pair<int, int> > shots(m);
  for (int j = 0; j < m; ++j) {
    int xj, yj;
    cin >> xj >> yj;
    shots[j] = pair<int, int>(xj, yj);
    if (!shotmap.count(shots[j])) shotmap[shots[j]] = j;
  }
  sort(shots.begin(), shots.end());
  for (int j = 0; j < m; j++) {
    long long xj = shots[j].first, yj = shots[j].second;
    vector<int>::iterator cit;
    cit = lower_bound(right.begin(), right.end(), xj);
    for (; cit != right.end(); ++cit) {
      int i = cit - right.begin();
      assert(0 <= i && i < n);
      if (xj < circles[i].first - circles[i].second) break;
      long long xi = circles[i].first, yi = 0, ri = circles[i].second;
      long long d2 = sqr(xi - xj) + sqr(yi - yj);
      if (d2 <= ri * ri) {
        int newid = shotmap[pair<int, int>(xj, yj)];
        if (!hitmap.count(xi) || hitmap[xi] > newid) hitmap[xi] = newid;
      }
    }
  }
  vector<int> ans(n, -1);
  for (typeof hitmap.begin() it = hitmap.begin(); it != hitmap.end(); ++it) {
    ans[cirmap[it->first]] = it->second + 1;
  }
  cout << hitmap.size() << endl;
  for (int i = 0; i < n; ++i) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}
int main() { solve(); }
