#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
inline long long read() {
  bool flag = 1;
  long long x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = 0;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return (flag ? x : ~(x - 1));
}
long long n, m, ans, c[10001], r[10001], s[10001];
vector<long long> v[100001];
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    c[i] = read() + 20000;
    r[i] = read();
    s[i] = -1;
    for (long long l = c[i] - r[i]; l <= c[i] + r[i]; l++) v[l].push_back(i);
  }
  m = read();
  for (long long i = 1; i <= m; i++) {
    long long x = read() + 20000, y = read();
    for (auto l : v[x])
      if (s[l] == -1)
        if (y * y + (x - c[l]) * (x - c[l]) <= r[l] * r[l]) {
          s[l] = i;
          ans++;
        }
  }
  cout << ans << endl;
  for (long long i = 1; i <= n; i++) cout << s[i] << " ";
  return 0;
}
