#include <bits/stdc++.h>
const int N = 100010;
const int inf = 0x3f3f3f3f;
using namespace std;
struct data {
  int x, r, id;
  bool operator<(const data &a) const {
    if (x != a.x) return x < a.x;
    return r < a.r;
  }
  data() {}
  data(int x, int r, int id) : x(x), r(r), id(id) {}
};
int ret[N];
set<data> st;
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, r;
    scanf("%d%d", &x, &r);
    st.insert(data(x, r, i + 1));
  }
  memset(ret, -1, sizeof(ret));
  int cnt = 0;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    set<data>::iterator it = st.upper_bound(data(x, y, 0));
    if (it != st.end()) {
      data u = (*it);
      if ((x - u.x) * (x - u.x) + y * y <= u.r * u.r) {
        if (ret[u.id] == -1) ret[u.id] = i + 1, cnt++;
      }
    }
    if (it != st.begin()) {
      it--;
      data u = (*it);
      if ((x - u.x) * (x - u.x) + y * y <= u.r * u.r) {
        if (ret[u.id] == -1) ret[u.id] = i + 1, cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) printf("%d ", ret[i]);
  printf("\n");
  return 0;
}
