#include <bits/stdc++.h>
using namespace std;
long long n, m, a[1000000], c, t, l, r;
int main() {
  cin >> n >> m;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> c >> t;
    a[i] = a[i - 1] + c * t;
  }
  for (int i = 0; i < m; i++) {
    cin >> c;
    c %= a[n] + 1;
    l = 0, r = n + 2;
    while (l < r - 1) {
      long long f = (l + r) / 2;
      if (a[f] >= c && a[f - 1] < c) {
        cout << f << "\n";
        break;
      }
      if (a[f] > c)
        r = f;
      else
        l = f;
    }
  }
  return 0;
}
