#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7FFFFFFF - 7;
const long long INF64 = 0x7FFFFFFFFFFFFFFF - 7;
struct Circle {
  long long x, y, r, num;
  Circle(int _x = 0, int _y = 0, int _r = 0) : x(_x), y(_y), r(_r), num(0) {}
  inline friend bool operator<(const Circle &a, const Circle &b) {
    return a.x < b.x;
  }
  inline bool Belong(const Circle &a) {
    return (a.x - x) * (a.x - x) + (a.y - y) * (a.y - y) <= r * r;
  }
};
int main() {
  int n;
  cin >> n;
  vector<Circle> mas(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> mas[i].x >> mas[i].r;
    mas[i].num = i;
  }
  sort(mas.begin() + 1, mas.end());
  int m;
  cin >> m;
  vector<int> res(n + 1, INF);
  for (int i = 1; i <= m; ++i) {
    Circle u;
    cin >> u.x >> u.y;
    vector<Circle>::iterator t = lower_bound(mas.begin() + 1, mas.end(), u);
    for (int j = 0; t != mas.begin() + 1 && j < 2; --t, ++j)
      ;
    for (int j = 0; t != mas.end() && j < 3; ++t, ++j) {
      if (t->Belong(u)) res[t->num] = min(i, res[t->num]);
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (res[i] != INF) ++cnt;
  }
  cout << cnt << endl;
  for (int i = 1; i <= n; ++i) {
    cout << (res[i] == INF ? -1 : res[i]) << ' ';
  }
  cout << endl;
  return 0;
}
