#include <bits/stdc++.h>
using namespace std;
struct pai {
  int first, second, idx;
  bool operator<(const pai &a) const { return first < a.first; }
};
int dist(pai a, pair<int, int> b) {
  return (a.first - b.first) * (a.first - b.first) + b.second * b.second;
}
int main() {
  int n;
  scanf("%d", &n);
  pai ara[n];
  int ans[n];
  memset(ans, -1, sizeof ans);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &ara[i].first, &ara[i].second);
    ara[i].idx = i;
  }
  sort(ara, ara + n);
  int m;
  scanf("%d", &m);
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    int l = 0, r = n - 1;
    pair<int, int> now;
    scanf("%d %d", &now.first, &now.second);
    int ansi;
    while (l <= r) {
      int mid1 = l + (r - l) / 3, mid2 = r - (r - l) / 3;
      if (dist(ara[mid1], now) <= dist(ara[mid2], now)) {
        ansi = mid1;
        r = mid2 - 1;
      } else {
        ansi = mid2;
        l = mid1 + 1;
      }
    }
    if (dist(ara[ansi], now) <= ara[ansi].second * ara[ansi].second) {
      if (ans[ara[ansi].idx] == -1) ans[ara[ansi].idx] = i, cnt++;
    }
    if (ansi + 1 < n) {
      ansi++;
      if (dist(ara[ansi], now) <= ara[ansi].second * ara[ansi].second) {
        if (ans[ara[ansi].idx] == -1) ans[ara[ansi].idx] = i, cnt++;
      }
      ansi--;
    }
    if (ansi - 1 >= 0) {
      ansi--;
      if (dist(ara[ansi], now) <= ara[ansi].second * ara[ansi].second) {
        if (ans[ara[ansi].idx] == -1) ans[ara[ansi].idx] = i, cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
