#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, pair<int, int> > > target;
int x, r, y;
vector<int> ans;
int bin_l(int x) {
  int l = 0;
  int r = n;
  int m = (l + r) / 2;
  while (l < r) {
    m = (l + r) / 2;
    if (x < target[m].first) {
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  return m;
}
int bin_r(int x) {
  int l = 0;
  int r = n - 1;
  int m = (l + r) / 2;
  while (l < r) {
    m = (l + r) / 2;
    if (x <= target[m].first) {
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  return m;
}
bool cmp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.first < b.first;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &r);
    target.push_back(make_pair(x, make_pair(i, r)));
  }
  sort(target.begin(), target.end(), cmp);
  ans.assign(n + 1, -1);
  scanf("%d", &m);
  int count = 0;
  int l;
  int r;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    int l = lower_bound(target.begin(), target.end(),
                        make_pair(x, make_pair(0, 0)), cmp) -
            target.begin();
    if (l <= n) {
      if (l == n) {
        l--;
        if ((x - target[l].first) * (x - target[l].first) + y * y <=
            target[l].second.second * target[l].second.second) {
          if (ans[target[l].second.first] == -1)
            ans[target[l].second.first] = i + 1;
        }
      } else {
        if ((x - target[l].first) * (x - target[l].first) + y * y <=
            target[l].second.second * target[l].second.second) {
          if (ans[target[l].second.first] == -1)
            ans[target[l].second.first] = i + 1;
        }
        if (l > 0) l--;
        if ((x - target[l].first) * (x - target[l].first) + y * y <=
            target[l].second.second * target[l].second.second) {
          if (ans[target[l].second.first] == -1)
            ans[target[l].second.first] = i + 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] > 0) count++;
  }
  cout << count << endl;
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
