#include <bits/stdc++.h>
using namespace std;
struct circle {
  int x;
  int r;
  int real;
};
bool operator<(circle x, circle y) { return x.x < y.x; }
int n, m;
int x, y;
int r;
int anss;
circle circles[10001];
int ans[100001], ans2[100001];
int abss(int a) {
  if (a < 0) a *= -1;
  return a;
}
void bsearch(int pi) {
  int mid, mini, maxi, xi;
  long dist;
  mini = 0;
  maxi = n - 1;
  mid = (mini + maxi) / 2;
  while (maxi - mini > 1) {
    mid = (mini + maxi) / 2;
    if (x < circles[mid].x - circles[mid].r) {
      maxi = mid;
    } else if (x > circles[mid].x + circles[mid].r) {
      mini = mid;
    } else {
      xi = abss(x - circles[mid].x);
      dist = xi * xi + y * y;
      if (dist < circles[mid].r * circles[mid].r) {
        if (ans[mid] == 0) {
          ans[mid] = pi;
          ans2[circles[mid].real] = pi;
          anss += 1;
        }
        break;
      } else if (dist == circles[mid].r * circles[mid].r) {
        if (ans[mid] == 0) {
          ans[mid] = pi;
          ans2[circles[mid].real] = pi;
          anss += 1;
        }
        if (mid - 1 >= 0) {
          xi = abss(x - circles[mid - 1].x);
          dist = xi * xi + y * y;
          if (dist == circles[mid - 1].r * circles[mid - 1].r &&
              ans[mid - 1] == 0) {
            ans[mid - 1] = pi;
            ans2[circles[mid - 1].real] = pi;
            anss += 1;
          }
        }
        if (mid + 1 < n) {
          xi = abss(x - circles[mid + 1].x);
          dist = xi * xi + y * y;
          if (dist == circles[mid + 1].r * circles[mid + 1].r &&
              ans[mid + 1] == 0) {
            ans[mid + 1] = pi;
            ans2[circles[mid + 1].real] = pi;
            anss += 1;
          }
        }
        break;
      } else
        break;
    }
  }
  if (maxi - mini == 1) {
    mid = mini;
    if (x < circles[mid].x - circles[mid].r) {
      maxi = mid;
    } else if (x > circles[mid].x + circles[mid].r) {
      mini = mid;
    } else {
      xi = abss(x - circles[mid].x);
      dist = xi * xi + y * y;
      if (dist < circles[mid].r * circles[mid].r) {
        if (ans[mid] == 0) {
          ans[mid] = pi;
          ans2[circles[mid].real] = pi;
          anss += 1;
        }
      } else if (dist == circles[mid].r * circles[mid].r) {
        if (ans[mid] == 0) {
          ans[mid] = pi;
          ans2[circles[mid].real] = pi;
          anss += 1;
        }
        if (mid - 1 >= 0) {
          xi = abss(x - circles[mid - 1].x);
          dist = xi * xi + y * y;
          if (dist == circles[mid - 1].r * circles[mid - 1].r &&
              ans[mid - 1] == 0) {
            ans[mid - 1] = pi;
            ans2[circles[mid - 1].real] = pi;
            anss += 1;
          }
        }
        if (mid + 1 < n) {
          xi = abss(x - circles[mid + 1].x);
          dist = xi * xi + y * y;
          if (dist == circles[mid + 1].r * circles[mid + 1].r &&
              ans[mid + 1] == 0) {
            ans[mid + 1] = pi;
            ans2[circles[mid + 1].real] = pi;
            anss += 1;
          }
        }
      }
    }
    mid = maxi;
    if (x < circles[mid].x - circles[mid].r) {
      maxi = mid;
    } else if (x > circles[mid].x + circles[mid].r) {
      mini = mid;
    } else {
      xi = abss(x - circles[mid].x);
      dist = xi * xi + y * y;
      if (dist < circles[mid].r * circles[mid].r) {
        if (ans[mid] == 0) {
          ans[mid] = pi;
          ans2[circles[mid].real] = pi;
          anss += 1;
        }
      } else if (dist == circles[mid].r * circles[mid].r) {
        if (ans[mid] == 0) {
          ans[mid] = pi;
          ans2[circles[mid].real] = pi;
          anss += 1;
        }
        if (mid - 1 >= 0) {
          xi = abss(x - circles[mid - 1].x);
          dist = xi * xi + y * y;
          if (dist == circles[mid - 1].r * circles[mid - 1].r &&
              ans[mid - 1] == 0) {
            ans[mid - 1] = pi;
            ans2[circles[mid - 1].real] = pi;
            anss += 1;
          }
        }
        if (mid + 1 < n) {
          xi = abss(x - circles[mid + 1].x);
          dist = xi * xi + y * y;
          if (dist == circles[mid + 1].r * circles[mid + 1].r &&
              ans[mid + 1] == 0) {
            ans[mid + 1] = pi;
            ans2[circles[mid + 1].real] = pi;
            anss += 1;
          }
        }
      }
    }
  }
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &circles[i].x, &circles[i].r);
    circles[i].real = i;
  }
  sort(circles, circles + n);
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    bsearch(i);
  }
  cout << anss << endl;
  if (ans2[0] == 0) ans2[0] = -1;
  cout << ans2[0];
  for (i = 1; i < n; i++) {
    if (ans2[i] == 0) ans2[i] = -1;
    cout << ' ' << ans2[i];
  }
}
