#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T sqr(T x) {
  return x * x;
}
int main() {
  int n;
  cin >> n;
  vector<int> res(n, INT_MAX);
  vector<pair<pair<int, int>, int> > circle(n);
  for (int i = 0; i < (n); i++) {
    scanf("%d %d", &circle[i].first.first, &circle[i].first.second);
    circle[i].second = i;
  }
  sort(circle.begin(), circle.end());
  int m;
  cin >> m;
  int x, y;
  for (int i = 0; i < (m); i++) {
    scanf("%d %d", &x, &y);
    vector<pair<pair<int, int>, int> >::iterator it = upper_bound(
        circle.begin(), circle.end(), make_pair(make_pair(x, INT_MAX), -1));
    if (it != circle.end() &&
        sqr(x - it->first.first) + sqr(y) <= sqr(it->first.second)) {
      res[it->second] = min(res[it->second], i);
    }
    if (it != circle.begin()) {
      it--;
      if (sqr(x - it->first.first) + sqr(y) <= sqr(it->first.second)) {
        res[it->second] = min(res[it->second], i);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < (n); i++) {
    if (res[i] == INT_MAX) {
      res[i] = -1;
    } else {
      res[i]++;
      cnt++;
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < (n); i++) printf("%d ", res[i]);
  return 0;
}
