#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
const int M = 200005;
struct seg {
  long long x, r;
  int id;
} s[N];
bool cmp(seg a, seg b) { return a.x < b.x; }
bool is_in(long long x, long long r, long long xx, long long yy) {
  if ((x - xx) * (x - xx) + yy * yy <= r * r) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int n, m;
  int ans[N], cnt = 0;
  long long x, y;
  long long low, high, mid;
  cin >> n;
  for (int i = 0; i < n; i++) {
    ans[i] = M;
    cin >> s[i].x >> s[i].r;
    s[i].id = i;
  }
  sort(s, s + n, cmp);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    low = 0;
    high = n - 1;
    while (low <= high) {
      mid = (low + high) / 2;
      if (x >= s[mid].x - s[mid].r && x <= s[mid].x + s[mid].r) {
        if (is_in(s[mid].x, s[mid].r, x, y)) {
          if (ans[s[mid].id] == M) cnt++;
          ans[s[mid].id] = min(ans[s[mid].id], i);
          if (x == s[mid].x - s[mid].r && mid > 0 &&
              s[mid - 1].x + s[mid - 1].r == x) {
            if (ans[s[mid - 1].id] == M) cnt++;
            ans[s[mid - 1].id] = min(ans[s[mid - 1].id], i);
          }
          if (x == s[mid].x + s[mid].r && mid < m &&
              s[mid + 1].x - s[mid + 1].r == x) {
            if (ans[s[mid + 1].id] == M) cnt++;
            ans[s[mid + 1].id] = min(ans[s[mid + 1].id], i);
          }
        }
        break;
      } else if (x > s[mid].x + s[mid].r) {
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << (ans[i] < M ? ans[i] : -1) << ' ';
  }
  cout << (ans[n - 1] < M ? ans[n - 1] : -1) << endl;
  return 0;
}
