#include <bits/stdc++.h>
struct point {
  int x, y;
};
struct circle {
  int x, r;
  int lx, rx;
  int rd;
  int num;
};
std::vector<struct circle> s;
std::vector<int> shots;
int donecnt = 0;
int n;
bool are_signs_equal(int i1, int i2) { return (i1 < 0) == (i2 < 0); }
int wherep(struct point *p, struct circle *c) {
  if (p->x < c->lx) return 1;
  if (p->x > c->rx) return -1;
  return 0;
}
void findncheck(struct point *p, int shotnum) {
  int l, m, r, resm;
  int lv, mv, rv;
  l = 0;
  r = n - 1;
  while (true) {
    m = (r - l) / 2 + l;
    lv = wherep(p, &s[l]);
    mv = wherep(p, &s[m]);
    rv = wherep(p, &s[r]);
    if (lv == 0) {
      resm = l;
      break;
    }
    if (mv == 0) {
      resm = m;
      break;
    }
    if (rv == 0) {
      resm = r;
      break;
    }
    if (l + 1 == r) return;
    if (!are_signs_equal(mv, rv)) {
      l = m;
    } else if (!are_signs_equal(lv, mv)) {
      r = m;
    } else {
      return;
    }
  }
  if ((p->x - s[resm].x) * (p->x - s[resm].x) + p->y * p->y > s[resm].rd)
    return;
  if (shots[s[resm].num] == -1) {
    shots[s[resm].num] = shotnum;
    donecnt++;
  }
  if ((resm > 0) &&
      ((p->x - s[resm - 1].x) * (p->x - s[resm - 1].x) + p->y * p->y <=
       s[resm - 1].rd)) {
    if (shots[s[resm - 1].num] == -1) {
      shots[s[resm - 1].num] = shotnum;
      donecnt++;
    }
  }
  if ((resm < n - 1) &&
      ((p->x - s[resm + 1].x) * (p->x - s[resm + 1].x) + p->y * p->y <=
       s[resm + 1].rd)) {
    if (shots[s[resm + 1].num] == -1) {
      shots[s[resm + 1].num] = shotnum;
      donecnt++;
    }
  }
}
int cmp(const struct circle &a, const struct circle &b) { return a.x < b.x; }
int main(int argc, char *argv[]) {
  int i;
  scanf("%d", &n);
  struct circle c;
  shots.resize(n);
  std::fill(shots.begin(), shots.end(), -1);
  s.resize(n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &c.x, &c.r);
    c.lx = c.x - c.r;
    c.rx = c.x + c.r;
    c.rd = c.r * c.r;
    c.num = i;
    s[i] = c;
  }
  std::sort(s.begin(), s.end(), cmp);
  int m;
  scanf("%d", &m);
  struct point p;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &p.x, &p.y);
    findncheck(&p, i + 1);
  }
  printf("%d\n", donecnt);
  for (i = 0; i < n; i++) {
    printf("%d ", shots[i]);
  }
  return 0;
}
