#include <bits/stdc++.h>
using namespace std;
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
const int N = 510 + 20;
bool is_inside(int x1, int y1, int x2, int y2, int r) {
  int dx = (x2 - x1);
  int dy = (y2 - y1);
  return dx * dx + dy * dy <= r * r;
}
int main() {
  file();
  fast();
  map<int, int> idx1;
  map<int, pair<int, int>> circle;
  int n;
  int m;
  cin >> n;
  vector<int> p(n);
  map<int, int> hit;
  for (int i = 0; i < n; i++) {
    int x, r;
    cin >> x >> r;
    circle[i + 1] = {x, r};
    idx1[x] = i + 1;
    p[i] = x;
  }
  sort(((p).begin()), ((p).end()));
  vector<int> ansf;
  int cnt = 0;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x2, y2;
    cin >> x2 >> y2;
    int idx = lower_bound(((p).begin()), ((p).end()), x2) - p.begin();
    int t_idx = idx;
    int ans = -1;
    for (int j = 0; j < 3 && t_idx < (int)p.size(); j++) {
      int r = circle[idx1[p[t_idx]]].second;
      int x = circle[idx1[p[t_idx]]].first;
      if (is_inside(x, 0, x2, y2, r)) {
        if (hit[idx1[p[t_idx]]] == 0) hit[idx1[p[t_idx]]] = i + 1;
      }
      t_idx++;
    }
    t_idx = idx;
    for (int j = 0; j < 3 && t_idx >= 0; j++) {
      int r = circle[idx1[p[t_idx]]].second;
      int x = circle[idx1[p[t_idx]]].first;
      if (is_inside(x, 0, x2, y2, r)) {
        if (hit[idx1[p[t_idx]]] == 0) hit[idx1[p[t_idx]]] = i + 1;
      }
      t_idx--;
    }
  }
  for (auto it : hit) {
    if (it.second != 0) {
      cnt++;
    }
  }
  cout << cnt << "\n";
  for (int i = 0; i < n; i++) {
    if (hit[i + 1] != 0) {
      cout << hit[i + 1] << " ";
    } else
      cout << -1 << " ";
  }
}
