#include <bits/stdc++.h>
using namespace std;
int temp[200001], ans[100001], ctr;
pair<pair<int, int>, int> a[200001];
int main() {
  int i, j, n, x, y, m, ind;
  memset(ans, -1, sizeof ans);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i].first.first;
    cin >> a[i].first.second;
    a[i].second = i;
  }
  sort(a, a + n);
  for (i = 0; i < n; i++) temp[i] = a[i].first.first;
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    ind = lower_bound(temp, temp + n, x) - temp;
    if (ind < n &&
        y * y + (a[ind].first.first - x) * (a[ind].first.first - x) <=
            a[ind].first.second * a[ind].first.second &&
        ans[a[ind].second] == -1)
      ans[a[ind].second] = i;
    ind--;
    if (ind >= 0 &&
        y * y + (a[ind].first.first - x) * (a[ind].first.first - x) <=
            a[ind].first.second * a[ind].first.second &&
        ans[a[ind].second] == -1)
      ans[a[ind].second] = i;
  }
  for (i = 0; i < n; i++) {
    if (ans[i] != -1) {
      ans[i]++;
      ctr++;
    }
  }
  cout << ctr << endl;
  for (i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
