#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
const int dx[] = {0, -1, 1, 0, 1, -1, 1, -1};
const int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const ll inf = 1e18L + 7;
const int N = 1e3 + 50;
vector<pair<int, pair<int, int> > > p;
int lbound(int x) {
  int lo = 0, hi = (int)p.size() - 1, mid, res = -1;
  while (lo <= hi) {
    mid = lo + hi >> 1;
    if (p[mid].first < x)
      lo = mid + 1;
    else
      res = mid, hi = mid - 1;
  }
  return res;
}
int ubound(int x) {
  int lo = 0, hi = (int)p.size() - 1, mid, res = -1;
  while (lo <= hi) {
    mid = lo + hi >> 1;
    if (p[mid].first <= x)
      lo = mid + 1, res = mid;
    else
      hi = mid - 1;
  }
  return res;
}
int sq(int x) { return x * x; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > c;
  for (int i = 0, x, r; i < n; ++i) {
    cin >> x >> r;
    c.emplace_back(x, r);
  }
  int m;
  cin >> m;
  for (int i = 0, x, y; i < m; ++i) {
    cin >> x >> y;
    p.push_back({x, {y, i + 1}});
  }
  sort(p.begin(), p.end());
  vector<int> ans(n, 1e9);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int l, r;
    l = lbound(c[i].first - c[i].second);
    r = ubound(c[i].first + c[i].second);
    if (l == -1) continue;
    for (int j = l; j <= r; ++j) {
      if (sq(p[j].first - c[i].first) + sq(p[j].second.first) <=
          sq(c[i].second))
        ans[i] = min(ans[i], p[j].second.second);
    }
    cnt += (ans[i] != 1e9);
  }
  cout << cnt << '\n';
  for (auto i : ans) cout << (i == 1e9 ? -1 : i) << ' ';
  return 0;
}
