#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long n, m;
vector<pair<pair<long long, long long>, long long> > cr;
long long x[maxn], y[maxn];
long long ans[maxn];
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    cr.push_back(make_pair(make_pair(a, b), i));
  }
  sort(cr.begin(), cr.end());
  memset(ans, -1, sizeof(ans));
  cin >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> x[i] >> y[i];
    long long pos = lower_bound(cr.begin(), cr.end(),
                                make_pair(make_pair(x[i], 0LL), 0LL)) -
                    cr.begin();
    if (pos < n) {
      long long d =
          (x[i] - cr[pos].first.first) * (x[i] - cr[pos].first.first) +
          y[i] * y[i];
      if (d <= cr[pos].first.second * cr[pos].first.second &&
          ans[cr[pos].second] == -1) {
        ans[cr[pos].second] = i;
      }
    }
    pos--;
    if (pos >= 0) {
      long long d =
          (x[i] - cr[pos].first.first) * (x[i] - cr[pos].first.first) +
          y[i] * y[i];
      if (d <= cr[pos].first.second * cr[pos].first.second &&
          ans[cr[pos].second] == -1) {
        ans[cr[pos].second] = i;
      }
    }
  }
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (ans[i] != -1) {
      cnt++;
    }
  }
  cout << cnt << endl;
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
