#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
const int mod = 100003;
const int INF = 0x3f3f3f;
int n, m, x, y;
int vis[N];
struct node {
  int x, r, i, v;
} tar[N];
bool cmp1(node &x, node &y) { return x.x < y.x; }
bool cmp2(node &x, node &y) { return x.i < y.i; }
int find(int x) {
  int l, mid, r;
  l = 1, r = n;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (tar[mid].x == x) return mid;
    if (tar[mid].x < x) l = mid;
    if (tar[mid].x > x) r = mid;
  }
  return l;
}
bool chk(int p, int x, int y) {
  if ((tar[p].x - x) * (tar[p].x - x) + y * y <= tar[p].r * tar[p].r)
    return true;
  else
    return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  memset(vis, 0, sizeof(vis));
  ;
  for (int i = 1; i <= n; i++) {
    cin >> tar[i].x >> tar[i].r;
    tar[i].v = -1;
    tar[i].i = i;
  }
  sort(tar + 1, tar + 1 + n, cmp1);
  cin >> m;
  int pos;
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    pos = find(x);
    if (tar[pos - 1].v == -1 && chk(pos - 1, x, y)) {
      tar[pos - 1].v = i;
      sum++;
    }
    if (tar[pos].v == -1 && chk(pos, x, y)) {
      tar[pos].v = i;
      sum++;
    }
    if (tar[pos + 1].v == -1 && chk(pos + 1, x, y)) {
      tar[pos + 1].v = i;
      sum++;
    }
  }
  sort(tar + 1, tar + 1 + n, cmp2);
  cout << sum << endl;
  for (int i = 1; i <= n; i++) {
    cout << tar[i].v << " ";
  }
  return 0;
}
