#include <bits/stdc++.h>
using namespace std;
const int maxl = 1000 * 10 + 5;
pair<int, int> a[maxl];
int n, m;
int ans[maxl];
int arr[maxl];
bool cmp(const int &i, const int &j) {
  if (a[i] == a[j]) return i < j;
  return a[i] < a[j];
}
bool hit(int x, int y, int i) {
  long long int dis = 0;
  x -= a[i].first;
  dis -= (long long int)(a[i].second) * (long long int)(a[i].second);
  dis += (long long int)(y) * (long long int)(y);
  dis += (long long int)(x) * (long long int)(x);
  return (dis <= 0);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    arr[i] = i;
  }
  sort(arr, arr + n, cmp);
  memset(ans, -1, sizeof ans);
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int lo = 0, hi = n;
    while (hi - lo != 1) {
      int mid = (hi + lo) / 2;
      int ind = arr[mid];
      if (a[ind].first <= x)
        lo = mid;
      else
        hi = mid;
    }
    if (hit(x, y, arr[lo]) && ans[arr[lo]] == -1) ans[arr[lo]] = i + 1;
    if (hit(x, y, arr[hi]) && ans[arr[hi]] == -1 && hi != n)
      ans[arr[hi]] = i + 1;
  }
  int tmp = 0;
  for (int i = 0; i < n; i++) tmp += (ans[i] != -1);
  cout << tmp << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
