#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
const int D = 20000;
int n, m;
int s[2 * D + 5], z;
vector<int> ans[2 * D + 5];
int c[D], r[D];
int main() {
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> c[i] >> r[i];
    c[i] += D;
    s[i] = -1;
    for (int j = c[i] - r[i]; j <= c[i] + r[i]; j++) ans[j].push_back(i);
  }
  cin >> m;
  for (int i = 0; i <= m - 1; i++) {
    int x, y;
    cin >> x >> y;
    x += D;
    for (auto u : ans[x]) {
      if (s[u] == -1)
        if (y * y + (c[u] - x) * (c[u] - x) <= r[u] * r[u]) s[u] = i + 1, z++;
    }
  }
  cout << z << "\n";
  for (int i = 0; i <= n - 1; i++) cout << s[i] << " ";
}
