#include <bits/stdc++.h>
using namespace std;
const long long nax = 3e5 + 5;
vector<long long> adj[nax];
const long long mod = 1e9 + 7;
const long long inf = 1e18 + 7;
const long long P = 2e4 + 5;
long long n, m;
long long a[nax], b[nax], ans[nax];
bool check(long long x, long long Y, long long X, long long R) {
  if (((X - x) * (X - x)) + (Y * Y) <= R * R) {
    return true;
  } else
    return false;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    for (long long j = a[i] - b[i]; j <= a[i] + b[i]; j++) {
      adj[j + P].push_back(i);
    }
  }
  cin >> m;
  long long cnt = 0;
  memset(ans, -1, sizeof(ans));
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    for (long long j : adj[x + P]) {
      long long X = a[j];
      long long R = b[j];
      if (ans[j] == -1 && check(x, y, X, R)) {
        cnt++;
        ans[j] = i;
      }
    }
  }
  cout << cnt << "\n";
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  return 0;
}
