#include <bits/stdc++.h>
using namespace std;
double dist(int x, int y, int a, int b) {
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  cout.precision(10);
  int n, m;
  cin >> n;
  int c, r;
  vector<pair<pair<int, int>, int> > arr;
  for (int i = 0; i < n; i++) {
    cin >> c >> r;
    arr.emplace_back(pair<int, int>(c, r), i);
  }
  sort(arr.begin(), arr.end());
  int centre[n];
  for (int i = 0; i < n; i++) {
    centre[i] = arr[i].first.first;
  }
  int count[n];
  for (int i = 0; i < n; i++) {
    count[i] = INT_MAX;
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (x <= centre[0]) {
      if (dist(x, y, arr[0].first.first, 0) <= arr[0].first.second) {
        count[0] = min(count[0], i);
      }
    } else if (x >= arr[n - 1].first.first) {
      if (dist(x, y, arr[n - 1].first.first, 0) <= arr[n - 1].first.second) {
        count[n - 1] = min(count[n - 1], i);
      }
    } else {
      int pos = upper_bound(centre, centre + n, x) - centre;
      if (dist(x, y, arr[pos].first.first, 0) <= arr[pos].first.second) {
        count[pos] = min(count[pos], i);
      }
      if (dist(x, y, arr[pos - 1].first.first, 0) <=
          arr[pos - 1].first.second) {
        count[pos - 1] = min(count[pos - 1], i);
      }
    }
  }
  int sol[n];
  int res = 0;
  for (int i = 0; i < n; i++) {
    sol[arr[i].second] = count[i];
    if (count[i] != INT_MAX) {
      res++;
    }
  }
  cout << res << ("\n");
  for (int i = 0; i < n; i++) {
    if (sol[i] != INT_MAX) {
      cout << sol[i] << " ";
    } else {
      cout << -1 << " ";
    }
  }
  return 0;
}
