#include <bits/stdc++.h>
using namespace std;
void outputDebug(const char* msg) {}
int a[100001];
int shut[90001] = {0};
bool dist(const pair<int, int>& c, int x, int y) {
  return ((c.first - x) * (c.first - x)) + ((y) * (y)) <= c.second * c.second;
}
int main() {
  outputDebug("Output debug:\n");
  int n;
  cin >> n;
  int x1, r;
  vector<pair<int, int> > v;
  vector<int> v1(n + 1, -1);
  int sh = 4 * 1e4;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> r;
    shut[x1 - r + sh] += i + 1;
    shut[x1 + r + 1 + sh] += -(i + 1);
    v.push_back(make_pair(x1, r));
  }
  for (int i = 0; i < 90001; i++) {
    if (i) shut[i] += shut[i - 1];
  }
  int m;
  cin >> m;
  int x, y;
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    int id1 = shut[x - 1 + sh];
    int id2 = shut[x + sh];
    int id3 = shut[x + 1 + sh];
    if (id2 != 0) {
      if (id1 != 0 && id3 != 0) {
        if (id1 != id3 && id2 != id1 && id2 != id3 && id2 > id1 && id2 > id3) {
          if (v1[id1 - 1] == -1 && dist(v[id1 - 1], x, y)) {
            v1[id1 - 1] = i + 1;
            cnt++;
          }
          if (v1[id3 - 1] == -1 && dist(v[id3 - 1], x, y)) {
            v1[id3 - 1] = i + 1;
            cnt++;
          }
        } else {
          if (v1[id2 - 1] == -1 && dist(v[id2 - 1], x, y)) {
            v1[id2 - 1] = i + 1;
            cnt++;
          }
        }
      } else {
        if (v1[id2 - 1] == -1 && dist(v[id2 - 1], x, y)) {
          v1[id2 - 1] = i + 1;
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < v1.size() - 1; i++) {
    printf("%d ", v1[i]);
  }
  return 0;
}
