#include <bits/stdc++.h>
using namespace std;
bool ifInside(int a, int r, int x, int y) {
  if (((x - a) * (x - a) + y * y - r * r) <= 0)
    return true;
  else
    return false;
}
int main(void) {
  int n, m;
  cin >> n;
  vector<pair<int, pair<int, int> > > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second.first;
    v[i].second.second = i;
  }
  sort(v.begin(), v.end());
  vector<int> xs;
  for (int i = 0; i < v.size(); i++) xs.push_back(v[i].first);
  cin >> m;
  int x, y, cc = 0;
  vector<int> re(n, -1);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (x <= xs[0]) {
      if (ifInside(v[0].first, v[0].second.first, x, y)) {
        if (re[v[0].second.second] == -1) {
          re[v[0].second.second] = i;
          cc++;
        }
      }
    } else if (x >= xs[xs.size() - 1]) {
      if (ifInside(v[v.size() - 1].first, v[v.size() - 1].second.first, x, y)) {
        if (re[v[v.size() - 1].second.second] == -1) {
          re[v[v.size() - 1].second.second] = i;
          cc++;
        }
      }
    } else {
      vector<int>::iterator it = upper_bound(xs.begin(), xs.end(), x);
      int in = it - xs.begin();
      bool b = false;
      if (ifInside(v[in].first, v[in].second.first, x, y)) {
        if (re[v[in].second.second] == -1) {
          re[v[in].second.second] = i;
          cc++;
        }
      }
      if (ifInside(v[in - 1].first, v[in - 1].second.first, x, y)) {
        if (re[v[in - 1].second.second] == -1) {
          re[v[in - 1].second.second] = i;
          cc++;
        }
      }
    }
  }
  cout << cc << endl;
  for (int i = 0; i < n; i++) {
    if (re[i] != -1)
      cout << re[i] + 1;
    else
      cout << re[i];
    if (i != n - 1) cout << " ";
  }
  return 0;
}
