#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
struct node {
  int x, r, id;
  friend bool operator<(node a, node b) { return a.x < b.x; }
  void od() { cout << x << " " << r << " " << id << endl; }
  node() {}
  node(int i, int j, int k) : x(i), r(j), id(k) {}
};
vector<node> vec;
vector<node> shot;
int ans[MAXN];
bool hit(int x, int y, int o, int r) {
  return r * r >= (x - o) * (x - o) + y * y;
}
int main() {
  int n, m;
  while (~scanf("%d", &n)) {
    vec.clear();
    shot.clear();
    int x, y;
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &x, &y);
      vec.push_back(node(x, y, i));
    }
    sort(vec.begin(), vec.end());
    memset(ans, -1, sizeof(ans));
    int len = vec.size() - 1;
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &x, &y);
      int now = -1;
      int l = 0;
      int r = len;
      while (l <= r) {
        int mid = (l + r) / 2;
        if (vec[mid].x - vec[mid].r <= x && x <= vec[mid].x + vec[mid].r) {
          now = mid;
          break;
        }
        if (vec[mid].x - vec[mid].r > x)
          r = mid - 1;
        else
          l = mid + 1;
      }
      if (now != -1) {
        for (int j = max(0, now - 10); j <= min(now + 10, len); j++) {
          if (hit(x, y, vec[j].x, vec[j].r)) {
            int id = vec[j].id;
            if (ans[id] == -1) ans[id] = i;
          }
        }
      }
    }
    int sum = 0;
    for (int i = 1; i <= n; i++) sum += ans[i] != -1;
    cout << sum << endl;
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    puts("");
  }
  return 0;
}
