#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1000000007;
map<long long, int> freq;
void update(long long i, int val) {
  while (i <= 1000000000) {
    freq[i] += val;
    i += i & -i;
  }
}
long long read(long long i) {
  long long sum = 0;
  while (i > 0) {
    sum += freq[i];
    i -= i & -i;
  }
  return sum;
}
int main() {
  int n, m;
  int t, c;
  long long tl = 0;
  int song;
  cin >> n >> m;
  update(1, 1);
  for (int i = 1; i <= n; i++) {
    cin >> c >> t;
    tl += (c * t);
    update(tl + 1, 1);
  }
  for (int i = 0; i < m; i++) {
    cin >> tl;
    song = read(tl);
    cout << song << "\n";
  }
  return 0;
}
