#include <bits/stdc++.h>
using namespace std;
int strike[10010];
bool isIn(long long x, long long y, long long cx, long long cr) {
  return (x - cx) * (x - cx) + y * y <= cr * cr;
}
int main() {
  int n, m;
  cin >> n;
  vector<pair<pair<long long, long long>, int> > mish(n + 2);
  for (int i = 1; i <= n; i++)
    cin >> mish[i].first.first >> mish[i].first.second, mish[i].second = i;
  n += 1;
  mish[0].first.first = -100000;
  mish[0].first.second = 0;
  mish[n].first.first = 100000;
  mish[n].first.second = 0;
  sort(mish.begin(), mish.end());
  for (int i = 1; i <= n; i++) strike[i] = -1;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    int l = 0, r = n;
    while (l < r) {
      int s = (l + r) / 2 + 1;
      if (x < mish[s].first.first)
        r = s - 1;
      else
        l = s;
    }
    if (strike[mish[l].second] == -1 &&
        isIn(x, y, mish[l].first.first, mish[l].first.second))
      strike[mish[l].second] = i;
    if (strike[mish[l + 1].second] == -1 &&
        isIn(x, y, mish[l + 1].first.first, mish[l + 1].first.second))
      strike[mish[l + 1].second] = i;
  }
  int c = 0;
  for (int i = 1; i < n; i++)
    if (strike[i] != -1) c++;
  cout << c << endl;
  for (int i = 1; i < n; i++) cout << strike[i] << " ";
exit:
  return (0);
}
