#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimize("-fno-defer-pop")
long long int power(long long int a, long long int b, long long int m) {
  if (b == 0) return 1;
  if (b == 1) return a % m;
  long long int t = power(a, b / 2, m) % m;
  t = (t * t) % m;
  if (b & 1) t = ((t % m) * (a % m)) % m;
  return t;
}
long long int modInverse(long long int a, long long int m) {
  return power(a, m - 2, m);
}
const long long int N = 200005;
long long int n, m;
long long int x[N], r[N], ans[N], c = 0;
map<long long int, long long int> getR, idx;
vector<long long int> vc;
void check(long long int i, long long int x, long long int x1,
           long long int y1) {
  long long int r = getR[x];
  if ((x - x1) * (x - x1) + y1 * y1 <= r * r) {
    if (ans[idx[x]] == 0) {
      c++;
      ans[idx[x]] = i;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, l, n, m;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x[i] >> r[i];
    getR[x[i]] = r[i];
    vc.push_back(x[i]);
    idx[x[i]] = i;
  }
  sort(vc.begin(), vc.end());
  cin >> m;
  for (i = 1; i <= m; i++) {
    long long int x, y;
    cin >> x >> y;
    auto it = lower_bound(vc.begin(), vc.end(), x);
    if (it != vc.end()) {
      check(i, *it, x, y);
    }
    if (it != vc.begin()) {
      it--;
      check(i, *it, x, y);
    }
  }
  cout << c << "\n";
  for (i = 1; i <= n; i++) {
    if (!ans[i])
      cout << "-1 ";
    else
      cout << ans[i] << " ";
  }
  return 0;
}
