#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
long long done[200004];
map<pair<long long, long long>, long long> mpp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long i, j, x, r;
  vector<pair<long long, long long> > v;
  vector<long long> v1;
  for (i = 1; i <= n; i++) {
    cin >> x >> r;
    mpp[{x, r}] = i;
    v.push_back({x, r});
    v1.push_back(x);
  }
  sort((v).begin(), (v).end());
  sort((v1).begin(), (v1).end());
  long long m;
  cin >> m;
  memset(done, 0, sizeof(done));
  long long cnt = 0;
  i = 0;
  while (m--) {
    long long x, y;
    cin >> x >> y;
    i++;
    long long l = lower_bound((v1).begin(), (v1).end(), x) - v1.begin();
    if (l < v1.size()) {
      long long x1 = v1[l];
      long long y1 = 0;
      long long dist = (x - x1) * (x - x1) + (y * y);
      if (dist <= (v[l].second * v[l].second)) {
        long long ind = mpp[v[l]];
        if (done[ind] == 0) done[ind] = i;
      }
    }
    long long u = l;
    u--;
    if (u >= 0) {
      long long x1 = v1[u];
      long long y1 = 0;
      long long dist = (x - x1) * (x - x1) + (y * y);
      if (dist <= (v[u].second * v[u].second)) {
        long long ind = mpp[v[u]];
        if (done[ind] == 0) done[ind] = i;
      }
    }
  }
  for (i = 1; i <= n; i++)
    if (done[i]) cnt++;
  cout << cnt << "\n";
  for (i = 1; i <= n; i++)
    if (!done[i])
      cout << -1 << " ";
    else
      cout << done[i] << " ";
  return 0;
}
