#include <bits/stdc++.h>
using namespace std;
int fastio() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  return 0;
}
int __fastio = fastio();
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
void solve() {
  int n;
  cin >> n;
  map<int, pair<int, int>> line;
  for (int i = 0; i < n; i++) {
    int x, r;
    cin >> x >> r;
    line[x] = {r, i};
  }
  vector<int> res(n, -1);
  int m;
  cin >> m;
  int x, y;
  auto inCircle = [](int x, int y, int x2, int r) {
    long long dx = x - x2, dy = y, r2 = 1LL * r * r;
    return dx * dx + dy * dy <= r2;
  };
  for (int j = 1; j <= m; j++) {
    cin >> x >> y;
    auto it = line.lower_bound(x);
    if (it != line.end()) {
      auto [x1, k] = *it;
      auto [r, idx] = k;
      if (res[idx] == -1 && inCircle(x, y, x1, r)) res[idx] = j;
    }
    if (it != line.begin()) {
      --it;
      auto [x1, k] = *it;
      auto [r, idx] = k;
      if (res[idx] == -1 && inCircle(x, y, x1, r)) res[idx] = j;
    }
  }
  int hit = n - count(res.begin(), res.end(), -1);
  cout << hit << "\n";
  for (int i = 0; i < n; i++) cout << res[i] << " \n"[i == n - 1];
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
