#include <bits/stdc++.h>
using namespace std;
int dcmp(double a, double b) {
  return fabs(a - b) <= 0.0000000001 ? 0 : (a > b) ? 1 : -1;
}
vector<pair<int, int> > v;
int ans[10000 + 9], v1[100000 + 9];
map<pair<int, int>, int> mb;
bool check(double x1, double y1, double x2, double y2, double r) {
  double d;
  int a, b, c;
  a = x2 - x1;
  b = y2 - y1;
  c = a * a + b * b;
  d = sqrt(c);
  if (dcmp(d, r) != 1) return 1;
  return 0;
}
int main() {
  int t, i, x, r, m, id, x1, y1, cnt = 0;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> x >> r;
    v.push_back(make_pair(x - r, r));
    mb[make_pair(x - r, r)] = i;
  }
  sort(((v).begin()), ((v).end()));
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x1 >> y1;
    if (v[0].first > x1) continue;
    id = (upper_bound(v.begin(), v.end(), make_pair(x1, 1000000000)) -
          v.begin()) -
         1;
    if (check(x1, y1, v[id].second + v[id].first, 0, v[id].second) &&
        ans[id] == 0) {
      ans[id] = i + 1;
      cnt++;
    }
    if ((id - 1 >= 0) && ((v[id - 1].first + v[id - 1].second * 2) == x1) &&
        (v[id].first == x1) && (ans[id - 1] == 0) && y1 == 0) {
      ans[id - 1] = i + 1;
      cnt++;
    }
  }
  cout << cnt << endl;
  for (i = 0; i < t; i++) {
    int p1 = v[i].first;
    int p2 = v[i].second;
    v1[mb[make_pair(p1, p2)]] = ans[i];
  }
  for (i = 0; i < t; i++) {
    cout << (v1[i] == 0 ? -1 : v1[i]) << " ";
  }
}
