#include <bits/stdc++.h>
using namespace std;
int n, m;
int pre[1000005];
int son[1000005][2];
vector<int> vec[1000005];
vector<long long> ans[1000005];
void dfs(int x) {
  if (x * 2 <= n) dfs(x * 2);
  if (x * 2 + 1 <= n) dfs(x * 2 + 1);
  vec[x].push_back(0);
  sort(vec[x].begin(), vec[x].end());
  long long temp = 0;
  for (int i = 0; i < vec[x].size(); i++) {
    temp += vec[x][i];
    ans[x].push_back(temp);
  }
  int now = pre[x];
  x /= 2;
  while (x) {
    vec[x].push_back(now);
    now += pre[x];
    x >>= 1;
  }
}
long long ask(int x, int h) {
  int len = vec[x].size();
  if (vec[x][0] > h) return 0;
  if (vec[x][len - 1] <= h) return h * 1LL * len - ans[x][len - 1];
  int l = 0, r = len - 2, mid;
  while (l != r) {
    mid = (l + r + 1) >> 1;
    if (vec[x][mid] <= h)
      l = mid;
    else
      r = mid - 1;
  }
  return h * 1LL * (l + 1) - ans[x][l];
}
int main() {
  int s, h;
  long long ans, temp;
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &pre[i]);
    son[i / 2][i % 2] = pre[i];
  }
  dfs(1);
  while (m--) {
    scanf("%d%d", &s, &h);
    ans = ask(s, h);
    temp = 0;
    while (s / 2) {
      if (h - pre[s] >= 0) {
        h -= pre[s];
        ans += h;
        if ((s / 2) * 2 + !(s % 2) <= n && h >= son[s / 2][!(s % 2)])
          ans += ask((s / 2) * 2 + !(s % 2), h - son[s / 2][!(s % 2)]);
        s /= 2;
      } else
        break;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
