#include <bits/stdc++.h>
using namespace std;
int n, a[20000], m, x, y;
map<int, pair<int, int> > s;
map<int, int> ans;
vector<int> v;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    s[x] = {y, i};
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    auto it = lower_bound(v.begin(), v.end(), x);
    if (it == v.end()) it--;
    int d = ceil(sqrt(abs(*it - x) * abs(*it - x) + y * y));
    if (d <= s[*it].first && ans[s[*it].second] == 0) ans[s[*it].second] = i;
    if (it != v.begin()) {
      it--;
      int d = ceil(sqrt(abs(*it - x) * abs(*it - x) + y * y));
      if (d <= s[*it].first && ans[s[*it].second] == 0) ans[s[*it].second] = i;
    }
  }
  cout << ans.size() << endl;
  for (int i = 1; i <= n; i++)
    if (ans[i])
      cout << ans[i] << " ";
    else
      cout << "-1 ";
  return 0;
}
