#include <bits/stdc++.h>
using namespace std;
long long cnt[100002];
string s;
long long pre[100002];
long long fi(long long a, long long n) {
  long long b = n - a;
  long long i, cn = 0, ans = 0;
  if (a == 0) return 0;
  ans = pre[b];
  ans *= (pre[a] - 1);
  ans %= 1000000007;
  if (ans < 0) ans += 1000000007;
  return ans;
}
int main() {
  long long n, q, i, j;
  cin >> n >> q;
  pre[0] = 1;
  for (i = 1; i < 100001; i++) {
    pre[i] = (pre[i - 1]) * 2;
    pre[i] %= 1000000007;
    if (pre[i] < 1000000007) pre[i] += 1000000007;
  }
  cin >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == '0')
      cnt[i + 1] = cnt[i];
    else
      cnt[i + 1] = cnt[i] + 1;
  }
  while (q--) {
    long long l, r;
    cin >> l >> r;
    cout << fi(-cnt[l - 1] + cnt[r], r - l + 1) << endl;
  }
}
