#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void Compute(long long int n) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<pair<long long int, long long int> > v;
  vector<pair<long long int, long long int> > duplicate;
  long long int cop = n;
  long long int x, r;
  while (n--) {
    cin >> x >> r;
    v.emplace_back(make_pair(x, r));
  }
  copy(v.begin(), v.end(), inserter(duplicate, duplicate.begin()));
  sort(v.begin(), v.end());
  long long int m;
  cin >> m;
  long long int a, b;
  map<pair<long long int, long long int>, long long int> memo;
  for (long long int i = 0; i < v.size(); i++) {
    memo.insert(make_pair(v[i], -1));
  }
  long long int c = 0;
  for (long long int i = 0; i < m; i++) {
    cin >> a >> b;
    pair<long long int, long long int> p = make_pair(a, b);
    auto it1 = upper_bound(v.begin(), v.end(), p);
    long long int dist1 = it1 - v.begin();
    long long int x1, r1, x2, r2;
    if (it1 != v.begin()) {
      auto it2 = it1 - 1;
      tie(x1, r1, x2, r2) =
          make_tuple(it1->first, it1->second, it2->first, it2->second);
      if ((((x1 - a) * (x1 - a) + (b * b)) <= (r1 * r1)) and
          (memo[{x1, r1}] == -1))
        memo[{x1, r1}] = i + 1;
      if ((((x2 - a) * (x2 - a) + (b * b)) <= (r2 * r2)) and
          (memo[{x2, r2}] == -1))
        memo[{x2, r2}] = i + 1;
    } else {
      tie(x1, r1) = make_tuple(it1->first, it1->second);
      if ((((x1 - a) * (x1 - a) + (b * b)) <= (r1 * r1)) and
          (memo[{x1, r1}] == -1))
        memo[{x1, r1}] = i + 1;
    }
  }
  for (long long int i = 0; i < duplicate.size(); i++) {
    if (memo[duplicate[i]] != -1) c++;
  }
  cout << c << "\n";
  for (long long int i = 0; i < duplicate.size(); i++) {
    cout << memo[duplicate[i]] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  Compute(n);
}
