#include <bits/stdc++.h>
#pragma GCC optimize "trapv"
long long int power(long long int x, long long int b) {
  long long int p = 1;
  while (b > 0) {
    if (b & 1) {
      p = p * x;
      p %= 998244353;
    }
    b >>= 1;
    x *= x;
    x %= 998244353;
  }
  return p % 998244353;
}
using namespace std;
struct ppp {
  char a;
  long long int b, c, d;
};
long long int N;
struct lex_compare {
  bool operator()(ppp p1, ppp p2) {
    if (p1.a == p2.a) {
      if (p1.b == p2.b)
        return p1.c < p2.c;
      else
        return p1.b < p2.b;
    } else {
      return p1.a < p2.a;
    }
  }
};
bool comp(pair<long long int, long long int> p1,
          pair<long long int, long long int> p2) {
  return p1.second < p2.second;
}
pair<long long int, long long int> bs(
    pair<pair<long long int, long long int>, long long int> shots[],
    long long int m, long long int xmin, long long int xmax) {
  long long int l = -1, r = m;
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    if (shots[mid].first.first < xmin) {
      l = mid;
    } else {
      r = mid;
    }
  }
  pair<long long int, long long int> ans;
  ans.first = r;
  l = -1, r = m;
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    if (shots[mid].first.first <= xmax) {
      l = mid;
    } else {
      r = mid;
    }
  }
  ans.second = l;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n;
  cin >> n;
  pair<long long int, long long int> arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  long long int m;
  cin >> m;
  pair<pair<long long int, long long int>, long long int> shots[m];
  for (long long int i = 0; i < m; i++) {
    cin >> shots[i].first.first >> shots[i].first.second;
    shots[i].second = i;
  }
  sort(shots, shots + m);
  long long int ans[n];
  for (long long int i = 0; i < n; i++) {
    ans[i] = m + 1;
    long long int x = arr[i].first, r = arr[i].second;
    pair<long long int, long long int> temp = bs(shots, m, x - r, x + r);
    for (long long int j = temp.first; j <= temp.second; j++) {
      if (sqrt(pow(shots[j].first.first - x, 2) +
               pow(shots[j].first.second, 2)) <= r) {
        ans[i] = min(ans[i], shots[j].second);
      }
    }
  }
  long long int c = 0;
  for (long long int i = 0; i < n; i++) {
    if (ans[i] == m + 1)
      ans[i] = -2;
    else
      c++;
  }
  cout << c << "\n";
  for (long long int i = 0; i < n; i++) cout << ans[i] + 1 << " ";
  cout << "\n";
  return 0;
}
