#include <bits/stdc++.h>
using namespace std;
const long long inf = 9.2e18;
const int maxn = 1e6 + 7;
const int INF = 2.1e9;
const int MOD = 1e9 + 7;
const double eps = 1e-7;
const double PI = acos(-1.0);
int n, m, k;
vector<int> V[maxn];
vector<long long> pre[maxn];
int L[maxn];
void add(int x) {
  int l = 0;
  while (x) {
    V[x].push_back(l);
    l += L[x - 1];
    x >>= 1;
  }
}
long long query(int x, int h) {
  long long ans = 0;
  while (x && (h > 0)) {
    auto it = lower_bound(V[x].begin(), V[x].end(), h);
    if (it != V[x].begin()) {
      long long t = (long long)(it - V[x].begin());
      ans += t * h - pre[x][t - 1];
    }
    if (x != 1) {
      it = lower_bound(V[x].begin(), V[x].end(), h - 2 * L[x - 1]);
      if (it != V[x].begin()) {
        long long t = (long long)(it - V[x].begin());
        ans -= (t * (h - L[x - 1])) - (pre[x][t - 1] + t * L[x - 1]);
      }
    }
    h -= L[x - 1];
    x >>= 1;
  }
  return ans;
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i <= n; i++) {
      V[i].clear();
      pre[i].clear();
    }
    for (int i = 1; i <= n - 1; i++) scanf("%d", &L[i]);
    for (int i = 1; i <= n; i++) add(i);
    for (int i = 1; i <= n; i++) {
      sort(V[i].begin(), V[i].end());
      pre[i].push_back((long long)V[i][0]);
      for (int j = 1; j < V[i].size(); j++) {
        pre[i].push_back(pre[i][j - 1] + V[i][j]);
      }
    }
    while (m--) {
      int x, h;
      scanf("%d%d", &x, &h);
      long long ans = query(x, h);
      printf("%lld\n", ans);
    }
  }
  return 0;
}
