#include <bits/stdc++.h>
using namespace std;
struct st1 {
  int index;
  int x;
  int r;
};
struct st1 obj1[20000];
struct st2 {
  int index;
  int x;
  int y;
};
struct st2 obj2[200100];
bool comp1(struct st1 obj3, struct st1 obj4) { return (obj3.x < obj4.x); }
bool comp2(struct st2 obj3, struct st2 obj4) { return (obj3.x < obj4.x); }
int main() {
  int n, i, j, f, m, x, r;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> obj1[i].x >> obj1[i].r;
    obj1[i].index = i + 1;
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> obj2[i].x >> obj2[i].y;
    obj2[i].index = i + 1;
  }
  sort(obj1, obj1 + n, comp1);
  sort(obj2, obj2 + m, comp2);
  int pt = 0, count = 0, x1, y1, r1;
  map<int, int> mymap;
  for (i = 0; i < m; i++) {
    if (obj2[i].x <= obj1[pt].x + obj1[pt].r &&
        obj2[i].x >= obj1[pt].x - obj1[pt].r) {
      x1 = obj2[i].x - obj1[pt].x;
      y1 = obj2[i].y;
      r1 = obj1[pt].r;
      if (x1 * x1 + y1 * y1 <= r1 * r1) {
        if (mymap[pt] == 0) {
          count++;
          mymap[pt] = obj2[i].index;
        } else {
          if (mymap[pt] > obj2[i].index) {
            mymap[pt] = obj2[i].index;
          }
        }
        if (pt < n - 1 && obj2[i].x == obj1[pt + 1].x - obj1[pt + 1].r) {
          if (mymap[pt + 1] == 0) {
            count++;
            mymap[pt + 1] = obj2[i].index;
          } else {
            if (mymap[pt + 1] > obj2[i].index) {
              mymap[pt + 1] = obj2[i].index;
            }
          }
        }
      }
    }
    if (obj2[i].x > obj1[pt].x + obj1[pt].r) {
      pt++;
      i--;
    }
  }
  cout << count << "\n";
  map<int, int>::iterator it;
  int hash[100100];
  for (i = 0; i < n; i++) {
    if (mymap[i] != 0) {
      hash[obj1[i].index] = mymap[i];
    } else {
      hash[obj1[i].index] = -1;
    }
  }
  for (i = 1; i <= n; i++) {
    cout << hash[i] << " ";
  }
  cout << "\n";
  cin >> i;
  return 0;
}
