#include <bits/stdc++.h>
using namespace std;
int hits[10005];
struct circle {
  double x, y, rad;
  int hit_id, org_indx;
};
struct point {
  double x, y;
};
vector<circle> v;
vector<point> v_p;
double dist(circle a, point b) {
  double tmp;
  tmp = sqrt((b.x - a.x) * (b.x - a.x) + b.y * b.y);
  return tmp;
}
int com1(circle a, circle b) {
  if (a.x < b.x)
    return true;
  else
    return false;
}
int com2(circle a, circle b) {
  if (a.org_indx < b.org_indx)
    return true;
  else
    return false;
}
int sol(circle a, point b) {
  double dst = dist(a, b);
  if (dst < a.rad || (dst - a.rad) < 0.001)
    return 0;
  else if (b.x > (a.x + a.rad))
    return 1;
  else if (b.x < a.x - a.rad)
    return -1;
  else if (a.x - a.rad <= b.x && b.x <= a.x + a.rad)
    return 0;
}
int bin_srch(int low, int high, point bullet) {
  int mid = (low + high) / 2;
  int val;
  while (high >= low) {
    val = sol(v[mid], bullet);
    if (val == 0) break;
    if (val > 0) low = mid + 1;
    if (val < 0) high = mid - 1;
    mid = (low + high) / 2;
  }
  return mid;
}
int main(void) {
  int n, i, j, m, indx, tot_hit;
  circle tmp;
  point tmp1;
  double dst;
  while (scanf("%d", &n) == 1) {
    v.clear();
    v_p.clear();
    tmp.y = 0.0;
    tmp.hit_id = -1;
    for (i = 0; i < n; i++) {
      tmp.org_indx = i;
      scanf("%lf %lf", &tmp.x, &tmp.rad);
      v.push_back(tmp);
    }
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf("%lf %lf", &tmp1.x, &tmp1.y);
      v_p.push_back(tmp1);
    }
    sort(v.begin(), v.end(), com1);
    tot_hit = 0;
    for (i = 0; i < m; i++) {
      indx = bin_srch(0, (int)v.size() - 1, v_p[i]);
      dst = dist(v[indx], v_p[i]);
      if (dst < v[indx].rad || (dst - v[indx].rad) < 0.001) {
        if (v[indx].hit_id == -1) {
          v[indx].hit_id = i + 1;
          tot_hit++;
        }
        if (indx + 1 < (int)v.size()) {
          dst = dist(v[indx + 1], v_p[i]);
          if (dst < v[indx + 1].rad || (dst - v[indx + 1].rad) < 0.001) {
            if (v[indx + 1].hit_id == -1) {
              v[indx + 1].hit_id = i + 1;
              tot_hit++;
            }
          }
        }
        if (indx - 1 >= 0) {
          dst = dist(v[indx - 1], v_p[i]);
          if (dst < v[indx - 1].rad || (dst - v[indx - 1].rad) < 0.001) {
            if (v[indx - 1].hit_id == -1) {
              v[indx - 1].hit_id = i + 1;
              tot_hit++;
            }
          }
        }
      }
    }
    for (i = 0; i < n; i++) {
      hits[v[i].org_indx] = v[i].hit_id;
    }
    cout << tot_hit << endl;
    for (i = 0; i < n; i++) {
      if (i)
        cout << " " << hits[i];
      else
        cout << hits[i];
    }
    puts("");
  }
  return 0;
}
