#include <bits/stdc++.h>
using namespace std;
template <class T>
bool amin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool amax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int32_t MOD = 1e9 + 7;
int inp[2000101];
vector<long long> dist[2000101], sums[2000101];
long long get_v(long long node, long long h) {
  int p = lower_bound(dist[node].begin(), dist[node].end(), h + 1) -
          dist[node].begin();
  if (p == 0) return 0;
  return h * p - sums[node][p - 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 2; i <= n; i++) cin >> inp[i];
  for (int i = n; i > 0; i--) {
    int left = 2 * i, right = 2 * i + 1;
    int p1 = 0, p2 = 0;
    dist[i].push_back(0);
    while (p1 < dist[left].size() || p2 < dist[right].size()) {
      if (p1 >= dist[left].size() ||
          (p2 < dist[right].size() &&
           dist[left][p1] + inp[left] > dist[right][p2] + inp[right])) {
        dist[i].push_back(dist[right][p2++] + inp[right]);
      } else {
        dist[i].push_back(dist[left][p1++] + inp[left]);
      }
    }
    sums[i].push_back(dist[i][0]);
    for (int j = 1; j < dist[i].size(); j++)
      sums[i].push_back(sums[i].back() + dist[i][j]);
  }
  while (m-- > 0) {
    int a, h;
    cin >> a >> h;
    long long ans = 0, prev = -1;
    while (a) {
      if (h < 0) break;
      ans += h;
      if (2 * a <= n && prev != 2 * a) ans += get_v(2 * a, h - inp[2 * a]);
      if (2 * a + 1 <= n && prev != 2 * a + 1)
        ans += get_v(2 * a + 1, h - inp[2 * a + 1]);
      h -= inp[a];
      prev = a;
      a >>= 1;
    }
    cout << ans << '\n';
  }
  return 0;
}
