#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &arr);
template <typename T>
ostream &operator<<(ostream &os, vector<T> &arr);
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p);
template <typename T>
istream &operator>>(istream &is, vector<T> &arr) {
  typename vector<T>::iterator a;
  for (a = arr.begin(); a != arr.end(); a++) {
    is >> *a;
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &arr) {
  typename vector<T>::iterator a;
  for (a = arr.begin(); a != arr.end(); a++) {
    os << *a << " ";
  }
  os << endl;
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p) {
  os << p.first << " " << p.second << '\n';
  return os;
}
long long INF = 1e18;
long long MOD = 1e9 + 7;
long long mul(long long a, long long b) { return (a % MOD * b % MOD) % MOD; }
long long add(long long a, long long b) { return (a % MOD + b % MOD) % MOD; }
bool valid(int i, int j, int n, int m) {
  return i >= 0 && i < n && j >= 0 && j < m;
}
vector<pair<int, int>> dirs = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int main() {
  int n;
  cin >> n;
  int offset = 25000;
  vector<vector<int>> mark(50001, vector<int>());
  vector<pair<int, int>> target(n + 1);
  for (int i = int(1); i <= int(n); i++) {
    int x, r;
    cin >> x >> r;
    x += offset;
    target[i] = {x, r};
    for (int j = x - r; j <= x + r; j++) mark[j].push_back(i);
  }
  int m;
  cin >> m;
  int cnt = 0;
  vector<int> first(n + 1);
  for (int i = 0; i < int(m); i++) {
    int x, y;
    cin >> x >> y;
    x += offset;
    vector<int> targets = mark[x];
    for (int tar : targets) {
      long long dx = target[tar].first - x;
      long long r = target[tar].second;
      if (dx * dx + y * y <= r * r && !first[tar]) {
        first[tar] = i + 1;
        cnt++;
      }
    }
  }
  cout << cnt << '\n';
  for (int i = int(1); i <= int(n); i++)
    cout << (first[i] ? first[i] : -1) << " ";
}
