#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;
const int MAXN = 10086;
int r[MAXN], ans[MAXN];
long long sqr(long long x) { return x * x; }
int main() {
  int n, m, x, y;
  map<int, int> make_pair;
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    scanf("%d%d", &x, &r[i]);
    make_pair[x] = i;
  }
  fill(ans, ans + n, -1);
  scanf("%d", &m);
  for (int i = (0); i < (m); ++i) {
    scanf("%d%d", &x, &y);
    auto it = make_pair.lower_bound(x);
    if (it != make_pair.end()) {
      if (ans[it->second] == -1 &&
          sqr(x - it->first) + sqr(y) <= sqr(r[it->second])) {
        ans[it->second] = i + 1;
      }
    }
    if (it != make_pair.begin()) {
      --it;
      if (ans[it->second] == -1 &&
          sqr(x - it->first) + sqr(y) <= sqr(r[it->second])) {
        ans[it->second] = i + 1;
      }
    }
  }
  printf("%d\n", n - (int)count(ans, ans + n, -1));
  for (int i = (0); i < (n); ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
