#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
void cp() {
  int n;
  cin >> n;
  vector<pair<int, int> > circle(n), range(n);
  vector<int> ans(n, -1), res(n, -1);
  map<pair<int, int>, int> index_of;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    circle[i] = make_pair(a, b);
    range[i] = make_pair(a - b, a + b);
    index_of[range[i]] = i;
  }
  sort(range.begin(), range.end());
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    auto it = lower_bound(range.begin(), range.end(), make_pair(x, x));
    if (it != end(range)) {
      int ind = it - begin(range);
      if (x >= range[ind].first && x <= range[ind].second) {
        int rad = (range[ind].second - range[ind].first) / 2;
        int center = range[ind].first + rad;
        if ((x - center) * (x - center) + y * y <= rad * rad) {
          if (ans[ind] == -1) ans[ind] = i + 1;
        }
      }
      ind--;
      if (ind >= 0) {
        if (x >= range[ind].first && x <= range[ind].second) {
          int rad = (range[ind].second - range[ind].first) / 2;
          int center = range[ind].first + rad;
          if ((x - center) * (x - center) + y * y <= rad * rad) {
            if (ans[ind] == -1) ans[ind] = i + 1;
          }
        }
      }
    } else {
      int ind = n - 1;
      if (x >= range[ind].first && x <= range[ind].second) {
        int rad = (range[ind].second - range[ind].first) / 2;
        int center = range[ind].first + rad;
        if ((x - center) * (x - center) + y * y <= rad * rad) {
          if (ans[ind] == -1) ans[ind] = i + 1;
        }
      }
    }
  }
  int found = 0;
  for (int i = 0; i < n; i++) {
    res[index_of[range[i]]] = ans[i];
    if (ans[i] != -1) found++;
  }
  cout << found << '\n';
  for (int x : res) cout << x << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    cp();
  }
  return 0;
}
