#include <bits/stdc++.h>
using namespace std;
int w[1000006], n, m;
vector<int> v[1000006];
vector<long long> sum[1000006];
long long quary(int a, int h) {
  if (!a || v[a][0] > h) return 0;
  int pos = lower_bound(v[a].begin(), v[a].end(), h) - v[a].begin();
  while (pos == v[a].size() || v[a][pos] > h) pos--;
  return (pos + 1LL) * h - sum[a][pos];
}
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 2; i <= n; i++) scanf("%d", &w[i]);
  for (i = n; i >= 1; i--) {
    for (int x = i, y = 0; x; y += w[x], x >>= 1) {
      v[x].push_back(y);
      sum[x].push_back(0);
    }
    sort(v[i].begin(), v[i].end());
    sum[i][0] = v[i][0];
    for (j = 1; j < sum[i].size(); j++) sum[i][j] = sum[i][j - 1] + v[i][j];
  }
  while (m--) {
    int a, h;
    scanf("%d", &a);
    scanf("%d", &h);
    long long ans = quary(a, h);
    while (a > 1 && h > 0) {
      ans -= quary(a, h - 2 * w[a]) - quary(a >> 1, h -= w[a]);
      a >>= 1;
    }
    printf("%lld\n", ans);
  }
}
