#include <bits/stdc++.h>
using namespace std;
void Yahia74() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5 + 74, M = 1e4 + 74, OO = 0x3f3f3f3f, MOD = (int)1e9 + 7;
int ans[M];
pair<int, int> circles[M];
pair<int, int> shots[N];
map<pair<int, int>, int> indices;
int dis(int x1, int y1, int x2, int y2) {
  int ans = ceil((double)(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))));
  return ans;
}
int main() {
  Yahia74();
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> circles[i].first >> circles[i].second;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> shots[i].first >> shots[i].second;
    if (indices[shots[i]] != 0) continue;
    indices[shots[i]] = i + 1;
  }
  sort(shots, shots + m);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int idx =
        lower_bound(shots, shots + m,
                    make_pair((circles[i].first - circles[i].second), (-OO))) -
        shots;
    bool ok = false;
    int mn = OO;
    while (idx < m &&
           shots[idx].first >= circles[i].first - circles[i].second &&
           shots[idx].first <= circles[i].first + circles[i].second) {
      ok = dis(shots[idx].first, shots[idx].second, circles[i].first, 0) <=
           circles[i].second;
      if (ok) mn = min(mn, indices[shots[idx]]);
      ++idx;
    }
    if (mn != OO)
      ans[i] = mn, cnt++;
    else
      ans[i] = -1;
  }
  cout << cnt << '\n';
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
  return 0;
}
