#include <bits/stdc++.h>
template <class T>
T gcd(T a, T b) {
  return a == 0 ? b : gcd(b % a, a);
}
using namespace std;
struct point {
  int x, y, id;
  int dist(point &q) { return ((x - q.x) * (x - q.x) + (y - q.y) * (y - q.y)); }
  bool operator<(const point &q) const {
    return (x < q.x || (x == q.x && id < q.id));
  }
};
struct circle {
  point c;
  int r, id, ponto;
  bool flag;
  bool inside(point &q) { return (c.dist(q) <= r * r); }
  bool operator<(const circle &q) const { return (c.x < q.c.x); }
};
bool cmp(circle a, circle b) { return (a.id < b.id); }
point P[201000];
circle C[10100];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> C[i].c.x >> C[i].r;
    C[i].c.y = 0;
    C[i].flag = false;
    C[i].ponto = 2147483640;
    C[i].id = i;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> P[i].x >> P[i].y;
    P[i].id = i + 1;
  }
  sort(P, P + m);
  sort(C, C + n);
  int i = 0, j = 0;
  while (i < m && j < n) {
    if (P[i].x > C[j].c.x + C[j].r) {
      j++;
      continue;
    }
    if (P[i].x < C[j].c.x - C[j].r) {
      i++;
      continue;
    }
    if (C[j].inside(P[i])) {
      C[j].flag = true;
      C[j].ponto = min(C[j].ponto, P[i].id);
      if (j + 1 < n && C[j + 1].c.x - C[j + 1].r <= P[i].x &&
          P[i].x <= C[j + 1].c.x + C[j + 1].r) {
        j++;
        continue;
      } else
        i++;
    } else if (j + 1 < n && C[j + 1].inside(P[i])) {
      j++;
      continue;
    } else
      i++;
  }
  int cont = 0;
  for (int i = 0; i < n; i++)
    if (C[i].flag) cont++;
  cout << cont << endl;
  sort(C, C + n, cmp);
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << ' ';
    if (C[i].flag)
      cout << C[i].ponto;
    else
      cout << -1;
  }
  cout << endl;
  return 0;
}
