#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9;
int n, m, g[N], dep[N];
vector<int> vec[N];
vector<long long> sum[N];
void dfs(int u, int fa) {
  if (u > n) return;
  dep[u] = dep[fa] + g[u];
  dfs((u << 1), u);
  dfs((u << 1 | 1), u);
  if ((u << 1 | 1) <= n)
    merge(vec[(u << 1)].begin(), vec[(u << 1)].end(), vec[(u << 1 | 1)].begin(),
          vec[(u << 1 | 1)].end(), back_inserter(vec[u]));
  else if ((u << 1) <= n)
    vec[u].insert(vec[u].begin(), vec[(u << 1)].begin(), vec[(u << 1)].end());
  vec[u].push_back(dep[u]);
  sort(vec[u].begin(), vec[u].end());
  for (int i = 0; i < (int)vec[u].size(); i++) sum[u].push_back(vec[u][i]);
  for (int i = 1; i < (int)sum[u].size(); i++) sum[u][i] += sum[u][i - 1];
  return;
}
long long calc(int u, int x) {
  if (!vec[u].size()) return 0;
  int l = 0, r = vec[u].size() - 1;
  long long ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (vec[u][mid] <= x)
      l = mid + 1, ans = mid;
    else
      r = mid - 1;
  }
  if (ans != -1) ans = (ans + 1) * x - sum[u][ans];
  return max(ans, 0ll);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) scanf("%d", &g[i]);
  dfs(1, 0);
  for (int i = 1; i <= m; i++) {
    int a, h;
    scanf("%d%d", &a, &h);
    long long ans = calc(a, h + dep[a]), u = a;
    while ((u / 2) && h > 0) {
      h -= g[u];
      if (h <= 0) break;
      ans += h + calc(u ^ 1, dep[u ^ 1] + h - g[u ^ 1]);
      u /= 2;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
