#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
pair<int, pair<int, int> > x[100001];
int w[100001];
set<int> ans;
int X1, X2, l, mid, r, x0, R, res;
int bin_search(int X, int Y) {
  res = 0;
  X1 = X2 = -1;
  l = 0;
  r = n - 1;
  while (l + 1 < r) {
    mid = (l + r + 1) / 2;
    if (x[mid].first < X) {
      l = mid;
    } else {
      r = mid;
    }
  }
  x0 = x[l].first;
  R = x[l].second.first;
  if (((X - x0) * (X - x0) + Y * Y) <= (R * R)) {
    X1 = l;
    res++;
  }
  x0 = x[r].first;
  R = x[r].second.first;
  if (((X - x0) * (X - x0) + Y * Y) <= (R * R)) {
    if (res == 0)
      X1 = r;
    else
      X2 = r;
    res++;
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i].first >> x[i].second.first;
    x[i].second.second = i;
    w[i] = (int)1e9;
  }
  sort(x, x + n);
  cin >> m;
  int uk;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    uk = bin_search(a, b);
    if (uk >= 1) {
      ans.insert(x[X1].second.second);
      w[x[X1].second.second] = min(i + 1, w[x[X1].second.second]);
    }
    if (uk >= 2) {
      ans.insert(x[X2].second.second);
      w[x[X2].second.second] = min(i + 1, w[x[X2].second.second]);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < n; ++i) {
    if (w[i] == (int)1e9)
      cout << "-1 ";
    else
      cout << w[i] << ' ';
  }
  return 0;
}
