#include <bits/stdc++.h>
using namespace std;
long long labs(long long a) { return a < 0 ? (-a) : a; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
template <typename T>
struct Point {
  T x, y;
  Point() {}
  Point(T xx, T yy) : x(xx), y(yy) {}
};
template <typename T>
bool operator<(const Point<T> &p1, const Point<T> &p2) {
  return p1.x < p2.x || p1.x == p2.x && p1.y < p2.y;
}
struct Node {
  int x, r;
  int id;
};
map<int, Node> v;
vector<int> ans;
int res = 0;
void Boom(Point<int> p, map<int, Node>::iterator it, int num) {
  if (it == v.end()) return;
  if (ans[it->second.id] != -1) return;
  if ((it->second.x - p.x) * (it->second.x - p.x) + (p.y * p.y) <=
      it->second.r * it->second.r) {
    res++;
    ans[it->second.id] = num;
  }
}
int main() {
  int n, m;
  cin >> n;
  ans.assign(n, -1);
  Node node;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> node.x >> node.r;
    node.id = i;
    v[node.x + node.r] = node;
  }
  cin >> m;
  Point<int> p;
  map<int, Node>::iterator it;
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> p.x >> p.y;
    it = v.lower_bound(p.x);
    Boom(p, it, i + 1);
    if (it != v.end()) {
      it++;
      Boom(p, it, i + 1);
    }
  }
  cout << res << endl;
  for (int(i) = 0; (i) < (n); (i)++) {
    cout << ans[i] << " ";
  }
  return 0;
}
