#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 2e9;
const long long INF64 = 9e18;
const long double EPS = 1e-12;
const long double PI = 3.1415926535897932384626433832795028841;
const long long MD = 925262732;
const long long T = 634521;
const int N = 200010;
const int M = 201;
int n, m, ans[N], sum = 0;
pair<pair<int, int>, int> a[N], b[N];
int dist(pair<int, int> a, pair<int, int> b) {
  return ((a.first - b.first) * (a.first - b.first)) +
         ((a.second - b.second) * (a.second - b.second));
}
int main() {
  cin >> n;
  for (int i = 0; i < int(n); i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = i;
    ans[i] = INF;
  }
  sort(a, a + n);
  cin >> m;
  for (int i = 0; i < int(m); i++) {
    scanf("%d %d", &b[i].first.first, &b[i].first.second);
    b[i].second = i + 1;
  }
  sort(b, b + m);
  int j = 0, q = 0;
  for (int i = 0; i < int(n); i++)
    while (j < m && b[j].first.first <= a[i].first.first + a[i].first.second) {
      if (dist(b[j].first, make_pair(a[i].first.first, 0)) <=
          ((a[i].first.second) * (a[i].first.second))) {
        ans[a[i].second] = min(ans[a[i].second], b[j].second);
        if (dist(b[j].first, make_pair(a[i].first.first, 0)) ==
                ((a[i].first.second) * (a[i].first.second)) &&
            i + 1 < n &&
            dist(b[j].first, make_pair(a[i + 1].first.first, 0)) <=
                ((a[i + 1].first.second) * (a[i + 1].first.second)))
          ans[a[i + 1].second] = min(ans[a[i + 1].second], b[j].second);
      }
      j++;
    }
  for (int i = 0; i < int(n); i++)
    if (ans[i] != INF) sum++;
  cout << sum << endl;
  for (int i = 0; i < int(n); i++)
    if (ans[i] == INF)
      cout << -1 << ' ';
    else
      cout << ans[i] << ' ';
  return 0;
}
