#include <bits/stdc++.h>
using namespace std;
const long long maxn = 500005;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const long long MOD = 100000007;
const double eps = 1e-10;
long long qpow(long long a, long long b) {
  long long tmp = a % MOD, ans = 1;
  while (b) {
    if (b & 1) {
      ans *= tmp, ans %= MOD;
    }
    tmp *= tmp, tmp %= MOD, b >>= 1;
  }
  return ans;
}
long long lowbit(long long x) { return x & -x; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
long long mmax(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
long long mmin(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
void mod(long long& a) {
  a += MOD;
  a %= MOD;
}
bool chk(long long now) {}
long long half(long long l, long long r) {
  while (l <= r) {
    long long m = (l + r) / 2;
    if (chk(m))
      r = m - 1;
    else
      l = m + 1;
  }
  return l;
}
long long ll(long long p) { return p << 1; }
long long rr(long long p) { return p << 1 | 1; }
long long mm(long long l, long long r) { return (l + r) / 2; }
long long lg(long long x) {
  if (x == 0) return 1;
  return (long long)log2(x) + 1;
}
bool smleql(double a, double b) {
  if (a < b || fabs(a - b) <= eps) return true;
  return false;
}
double len(double a, double b, double c, double d) {
  return sqrt((a - c) * (a - c) + (b - d) * (b - d));
}
bool isp(long long x) {
  if (x == 1) return false;
  if (x == 2) return true;
  for (long long i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
inline long long read() {
  char ch = getchar();
  long long s = 0, w = 1;
  while (ch < 48 || ch > 57) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= 48 && ch <= 57) {
    s = (s << 1) + (s << 3) + ch - 48;
    ch = getchar();
  }
  return s * w;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
long long n, m;
struct node {
  long long x, r, id;
  node() {}
  node(long long X, long long R) : x(X), r(R) {}
  bool operator<(const node& o) const { return x < o.x; }
} o[maxn];
long long a, b, ans[maxn], tot = 0;
bool ok(long long a, long long b, long long p) {
  long long x = o[p].x;
  long long r = o[p].r;
  if (smleql(len((double)a, (double)b, (double)x, 0.0), (double)r)) return 1;
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> o[i].x >> o[i].r, o[i].id = i;
  sort(o + 1, o + 1 + n);
  for (long long i = 1; i <= n; ++i) ans[i] = -1;
  cin >> m;
  for (long long i = 1; i <= m; ++i) {
    cin >> a >> b;
    long long p = lower_bound(o + 1, o + 1 + n, node(a, 0)) - o;
    if (p <= n && ans[o[p].id] == -1 && ok(a, b, p)) ans[o[p].id] = i, tot++;
    p++;
    if (p <= n && ans[o[p].id] == -1 && ok(a, b, p)) ans[o[p].id] = i, tot++;
    p -= 2;
    if (p <= n && ans[o[p].id] == -1 && ok(a, b, p)) ans[o[p].id] = i, tot++;
  }
  cout << tot << endl;
  for (long long i = 1; i <= n; ++i) cout << ans[i] << ' ';
  return 0;
}
