#include <bits/stdc++.h>
const int MAX = (const int)(1e5 + 11);
using namespace std;
struct Point {
  int x, y;
  Point() : x(0), y(0) {}
};
struct Circle {
  Point center;
  int R;
  int idx;
  Circle() : R(0) {}
  inline bool Contains(const Point &point) {
    const auto dx = point.x - center.x;
    const auto dy = point.y - center.y;
    return dx * dx + dy * dy <= R * R;
  }
};
bool operator<(const Circle &lhs, const Circle &rhs) {
  return lhs.center.x + lhs.R < rhs.center.x + rhs.R;
}
static void solve(std::int32_t test) {
  int N;
  cin >> N;
  vector<Circle> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i].center.x >> A[i].R;
    A[i].idx = i;
  }
  sort(A.begin(), A.end());
  vector<int> result(N, -1);
  int M;
  cin >> M;
  for (int i = 0; i < M; ++i) {
    Point point;
    cin >> point.x >> point.y;
    Circle c;
    c.center = point;
    const auto &it = lower_bound(A.begin(), A.end(), c);
    if (it == A.end()) {
      if (result[A[N - 1].idx] == -1 && A[N - 1].Contains(point))
        result[A[N - 1].idx] = i + 1;
      if (result.size() > 1 && result[A[N - 2].idx] == -1 &&
          A[N - 2].Contains(point))
        result[A[N - 2].idx] = i + 1;
    } else if (it == A.begin()) {
      if (result[A[0].idx] == -1 && A[0].Contains(point))
        result[A[0].idx] = i + 1;
      if (result.size() > 1 && result[A[1].idx] == -1 && A[1].Contains(point))
        result[A[1].idx] = i + 1;
    } else {
      if (result[it->idx] == -1 && it->Contains(point)) result[it->idx] = i + 1;
      const auto &prv = it - 1;
      if (A.begin() > prv && result[prv->idx] == -1 && prv->Contains(point))
        result[prv->idx] = i + 1;
      const auto &nxt = it + 1;
      if (nxt < A.end() && result[nxt->idx] == -1 && nxt->Contains(point))
        result[nxt->idx] = i + 1;
    }
  }
  cout << N - std::count(result.begin(), result.end(), -1) << "\n";
  for (int i = 0; i < N; ++i) cout << result[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << setprecision(12) << fixed;
  solve(0);
  return 0;
}
