#include <bits/stdc++.h>
using namespace std;
const int INFint = 2e9;
const long long INF = 2e18;
const long long MOD = 1000000007ll;
long double dist(long double x, long double y, long double x1, long double y1) {
  return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<pair<int, pair<int, int> > > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second.first;
    v[i].first -= v[i].second.first;
    v[i].second.second = i;
  }
  sort(v.begin(), v.end());
  int m;
  cin >> m;
  vector<int> ans(n, -1);
  int cnt = 0;
  for (int T = 0; T < m; T++) {
    int x, y;
    cin >> x >> y;
    int it = (int)(lower_bound(v.begin(), v.end(),
                               make_pair(x, make_pair(-INFint, -INFint))) -
                   v.begin());
    if (it != n && ans[v[it].second.second] == -1 &&
        dist(v[it].first + v[it].second.first, 0, x, y) <= v[it].second.first) {
      cnt++;
      ans[v[it].second.second] = T + 1;
    }
    it--;
    if (it > -1 && ans[v[it].second.second] == -1 &&
        dist(v[it].first + v[it].second.first, 0, x, y) <= v[it].second.first) {
      cnt++;
      ans[v[it].second.second] = T + 1;
    }
  }
  cout << cnt << endl;
  for (auto x : ans) cout << x << ' ';
  fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
  ;
  return 0;
}
