#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n, m, ans[maxn];
vector<pair<int, int>> vals[2 * maxn];
pair<int, int> grid[maxn];
void solve() {
  memset(ans, 0x3f3f3f, sizeof(ans));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> grid[i].first >> grid[i].second;
  }
  cin >> m;
  for (int i = 1, x, y; i <= m; ++i) {
    cin >> x >> y;
    vals[x + maxn].push_back({y, i});
  }
  for (int i = 0; i < n; ++i) {
    int s = grid[i].first - grid[i].second, e = grid[i].first + grid[i].second;
    for (int j = s; j <= e; ++j) {
      for (auto p : vals[j + maxn]) {
        int x1 = grid[i].first, y1 = 0, x2 = j, y2 = p.first;
        if (hypot(abs(x1 - x2), abs(y1 - y2)) <= grid[i].second * 1.0) {
          ans[i] = min(ans[i], p.second);
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (ans[i] <= m) {
      cnt++;
    } else {
      ans[i] = -1;
    }
  }
  cout << cnt << '\n';
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
