#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T Abs(T a) {
  return a > 0 ? a : -a;
}
void split(string s, string seps, vector<string> &res, bool doEmpty = false) {
  int start = 0;
  res.clear();
  for (int i = 0; i < s.size(); i++) {
    if (seps.find(s[i]) != string::npos) {
      if (doEmpty || i - start > 0) res.push_back(s.substr(start, i - start));
      start = i + 1;
    }
  }
  if (doEmpty || s.size() - start > 0)
    res.push_back(s.substr(start, s.size() - start));
}
string Union(vector<string> s, int start = 0) {
  string res;
  for (int i = start; i < s.size(); i++) res.append(s[i]);
  return res;
}
int main() {
  int s = 0;
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  vector<int> r(n);
  vector<int> c(n);
  vector<int> res;
  res.assign(n, -2);
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> r[i];
    a[i].first = c[i] + r[i];
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int i1 = lower_bound(a.begin(), a.end(), make_pair(x, -1)) - a.begin();
    int i2 = i1 + 1;
    if (i2 < a.size()) {
      int ind = a[i2].second;
      long long rr = r[ind];
      if (a[i1 + 1].first - 2 * rr <= x) i2++;
    }
    for (int j = i1; j < min(i2, n); j++) {
      int ind = a[j].second;
      long long rr = r[ind];
      long long xx = ((long long)x - c[ind]) * ((long long)x - c[ind]);
      if (xx + (long long)y * y <= rr * rr && res[ind] < 0) {
        res[ind] = i;
      }
    }
  }
  s = 0;
  for (int i = 0; i < n; i++)
    if (res[i] >= 0) s++;
  cout << s << endl;
  for (int i = 0; i < n; i++) cout << (res[i] + 1) << ' ';
  return 0;
}
