#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000000;
pair<pair<int, int>, int> target[maxN], shot[maxN];
int res[maxN];
int sq(int x) { return x * x; }
int ins(pair<int, int> sh, pair<int, int> ta) {
  return sq(sh.first - ta.first) + sq(sh.second) <= sq(ta.second);
}
int main() {
  int n, m;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> target[i].first.first >> target[i].first.second;
    target[i].second = i;
  }
  sort(target, target + n);
  cin >> m;
  for (int i = 0; i < (m); ++i) {
    cin >> shot[i].first.first >> shot[i].first.second;
    shot[i].second = i;
  }
  sort(shot, shot + m);
  for (int i = 0; i < (n); ++i) res[i] = INT_MAX;
  int nt = 0;
  for (int i = 0; i < (m); ++i) {
    while (nt < n && shot[i].first.first >
                         target[nt].first.first + target[nt].first.second)
      nt++;
    if (nt == n) break;
    if (ins(shot[i].first, target[nt].first)) {
      res[target[nt].second] = (res[target[nt].second] > (shot[i].second))
                                   ? (shot[i].second)
                                   : res[target[nt].second];
    }
    if (nt + 1 < n && ins(shot[i].first, target[nt + 1].first)) {
      res[target[nt + 1].second] =
          (res[target[nt + 1].second] > (shot[i].second))
              ? (shot[i].second)
              : res[target[nt + 1].second];
    }
  }
  cout << n - count(res, res + n, INT_MAX) << endl;
  for (int i = 0; i < (n); ++i)
    cout << (res[i] == INT_MAX ? -1 : res[i] + 1) << (i + 1 == n ? '\n' : ' ');
  return 0;
}
