#include <bits/stdc++.h>
using namespace std;
inline void upmax(int &x, int b) {
  if (b > x) x = b;
}
inline void upmin(int &x, int b) {
  if (b < x) x = b;
}
inline void read(int &x) {
  x = 0;
  char c = getchar();
  for (; c < '0' || '9' < c; c = getchar())
    ;
  for (; '0' <= c && c <= '9'; c = getchar()) x = 10 * x + c - '0';
}
const int N = 100005;
int n, m;
int c[N], t[N], l[N], r[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &c[i], &t[i]);
  int times = 0;
  for (int i = 1; i <= n; ++i) {
    l[i] = times;
    times = r[i] = times + c[i] * t[i];
  }
  int ans = 1;
  for (int i = 1; i <= m; ++i) {
    int tnt;
    scanf("%d", &tnt);
    if (tnt > r[n]) {
      printf("Error\n");
      break;
    }
    while (r[ans] < tnt) ++ans;
    printf("%d\n", ans);
  }
  return 0;
}
