#include <bits/stdc++.h>
const int maxn = 1e5 + 5;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;
const long long int INF = 1e18 + 100;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
using namespace std;
int n, x[maxn], r[maxn], xx, yy, num, ans[maxn], m, cnt = 0;
struct {
  int x, y;
} a[20002 * 2];
int main() {
  cin >> n;
  memset(ans, -1, sizeof ans);
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> r[i];
    for (int j = x[i] - r[i]; j <= x[i] + r[i]; j++) {
      if (a[j + 20002].x)
        a[j + 20002].y = i;
      else
        a[j + 20002].x = i;
    }
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &xx, &yy);
    yy *= yy;
    xx += 20002;
    num = a[xx].x;
    if (num == 0) continue;
    xx -= 20002;
    if (ans[num] < 0)
      if ((x[num] - xx) * (x[num] - xx) + yy <= r[num] * r[num])
        ans[num] = i, ++cnt;
    xx += 20002;
    num = a[xx].y;
    if (num == 0) continue;
    xx -= 20002;
    if (ans[num] < 0)
      if ((x[num] - xx) * (x[num] - xx) + yy <= r[num] * r[num])
        ans[num] = i, ++cnt;
  }
  cout << cnt << endl;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
