#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
bool sortbysec(const pair<pair<int, int>, int> &a,
               const pair<pair<int, int>, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long int n, x, r;
  cin >> n;
  vector<pair<long long int, long long int> > v1;
  vector<pair<pair<long long int, long long int>, long long int> > v11;
  vector<long long int> v3;
  map<long long int, long long int> m1;
  for (int i = 0; i < n; i++) {
    cin >> x >> r;
    m1[x] = 0;
    v1.push_back({x, r});
    v11.push_back({{x, r}, i});
    v3.push_back(x);
  }
  long long int m;
  sort(v1.begin(), v1.end());
  cin >> m;
  vector<pair<long long int, long long int> > v2, v4;
  sort(v3.begin(), v3.end());
  long long int x1, y1, x2, y2;
  for (int i = 0; i < m; i++) {
    cin >> x1 >> y1;
    v2.push_back({x1, y1});
  }
  long long int ans = 0;
  for (int i = 0; i < v2.size(); i++) {
    x1 = v2[i].first;
    if (x1 <= v1[0].first) {
      r = v1[0].second;
      r = r * r;
      x2 = (v1[0].first - x1) * (v1[0].first - x1);
      y2 = (v2[i].second) * (v2[i].second);
      if ((x2 + y2) <= r) {
        if (m1[v1[0].first] == 0) {
          m1[v1[0].first] = i + 1;
        }
      }
    } else if (x1 >= v1[v1.size() - 1].first) {
      r = v1[v1.size() - 1].second;
      r = r * r;
      x2 = (v1[v1.size() - 1].first - x1) * (v1[v1.size() - 1].first - x1);
      y2 = (v2[i].second) * (v2[i].second);
      if ((x2 + y2) <= r) {
        if (m1[v1[v1.size() - 1].first] == 0) {
          m1[v1[v1.size() - 1].first] = i + 1;
        }
      }
    } else {
      vector<long long int>::iterator fin;
      fin = find(v3.begin(), v3.end(), x1);
      long long int l, h, mid;
      if (fin != v3.end()) {
        r = v1[fin - v3.begin()].second;
        r = r * r;
        x2 = (v1[fin - v3.begin()].first - x1) *
             (v1[fin - v3.begin()].first - x1);
        y2 = (v2[i].second) * (v2[i].second);
        if ((x2 + y2) <= r) {
          if (m1[v1[fin - v3.begin()].first] == 0) {
            m1[v1[fin - v3.begin()].first] = i + 1;
          }
        }
      } else {
        l = 0, h = n - 1, mid = (l + h) / 2;
        while ((h - l) != 1) {
          if (x1 < v3[mid]) {
            h = mid;
          } else {
            l = mid;
          }
          mid = (l + h) / 2;
        }
        long long int c1 = 0, c2 = 0;
        r = v1[l].second;
        r = r * r;
        x2 = (v1[l].first - x1) * (v1[l].first - x1);
        y2 = (v2[i].second) * (v2[i].second);
        if ((x2 + y2) <= r) {
          if (m1[v1[l].first] == 0) {
            c1 = 1;
            m1[v1[l].first] = i + 1;
          }
        }
        r = v1[h].second;
        r = r * r;
        x2 = (v1[h].first - x1) * (v1[h].first - x1);
        y2 = (v2[i].second) * (v2[i].second);
        if ((x2 + y2) <= r) {
          if (m1[v1[h].first] == 0) {
            c2 = 1;
            m1[v1[h].first] = i + 1;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (m1[v1[i].first] != 0) ans++;
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    if (m1[v11[i].first.first] == 0)
      cout << "-1"
           << " ";
    else
      cout << m1[v11[i].first.first] << " ";
  }
}
