#include <bits/stdc++.h>
using namespace std;
int n, m, tot, res[10010];
struct In {
  int c;
  int r;
  int id;
  int mark;
} s[10010];
int cmp(const void *a, const void *b) {
  struct In *c = (In *)a;
  struct In *d = (In *)b;
  return c->c - d->c;
}
int find_pos(int x) {
  int i, j, first, last, mid;
  first = 0;
  last = n - 1;
  while (first < last) {
    mid = (first + last) / 2;
    if (s[mid].c == x)
      return mid;
    else if (s[mid].c > x)
      last = mid - 1;
    else {
      if (s[mid + 1].c >= x)
        return mid;
      else
        first = mid + 1;
    }
  }
  return first;
}
int main() {
  while (cin >> n) {
    int i, j;
    for (i = 0; i < n; i++) {
      cin >> s[i].c >> s[i].r;
      s[i].id = i;
      s[i].mark = -1;
    }
    qsort(s, n, sizeof(s[0]), cmp);
    cin >> m;
    tot = 0;
    int a, b, p, q;
    for (i = 0; i < m; i++) {
      cin >> a >> b;
      int pos = find_pos(a);
      if (pos >= 0 && s[pos].mark == -1) {
        if (b * b + (a - s[pos].c) * (a - s[pos].c) <= s[pos].r * s[pos].r) {
          s[pos].mark = i + 1;
          tot++;
        }
      }
      if (pos + 1 < n && s[pos + 1].mark == -1) {
        if (b * b + (a - s[pos + 1].c) * (a - s[pos + 1].c) <=
            s[pos + 1].r * s[pos + 1].r) {
          s[pos + 1].mark = i + 1;
          tot++;
        }
      }
    }
    cout << tot << endl;
    for (i = 0; i < n; i++) res[s[i].id] = s[i].mark;
    cout << res[0];
    for (i = 1; i < n; i++) cout << ' ' << res[i];
    cout << endl;
  }
  return 0;
}
