#include <bits/stdc++.h>
using namespace std;
bool Comp(const pair<pair<int, int>, int>& a,
          const pair<pair<int, int>, int>& b) {
  return (a.first.first < b.first.first);
}
bool check(int res[], vector<pair<pair<int, int>, int>>::iterator it, int x,
           int y) {
  return (res[it->second] == -1 &&
          hypot(x - it->first.first, y) <= it->first.second);
}
int main() {
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int>> V;
  V.push_back(make_pair(make_pair(INT_MIN, 0), 0));
  for (int i = 1; i <= n; i++) {
    int x, r;
    cin >> x >> r;
    V.push_back(make_pair(make_pair(x, r), i));
  }
  V.push_back(make_pair(make_pair(INT_MAX, 0), n + 1));
  sort(V.begin(), V.end(), Comp);
  int m;
  cin >> m;
  int res[10010];
  memset(res, -1, sizeof(res));
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    auto it =
        upper_bound(V.begin(), V.end(), make_pair(make_pair(x, 0), 0), Comp);
    if (check(res, it, x, y)) {
      res[it->second] = i;
      cnt++;
    }
    it--;
    if (check(res, it, x, y)) {
      res[it->second] = i;
      cnt++;
    }
  }
  cout << cnt << endl;
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
exit:
  return (0);
}
