#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 100100;
char a[N];
long long sum[N];
long long qm(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b % 2) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return ans % mod;
}
int main() {
  long long n, q, l, r;
  cin >> n >> q;
  cin >> (a + 1);
  long long len = strlen(a + 1);
  sum[0] = 0;
  for (long long i = 1; i <= len; i++) {
    if (a[i] == '1') {
      sum[i] = sum[i - 1] + 1;
    } else {
      sum[i] = sum[i - 1];
    }
  }
  long long one, rel, zero;
  long long ans;
  while (q--) {
    cin >> l >> r;
    l--;
    ans = 0;
    one = r - l;
    rel = sum[r] - sum[l];
    zero = one - rel;
    ans += (qm((long long)2, rel) - 1) % mod;
    if (zero > 0) {
      ans = (ans % mod + ans % mod * (qm((long long)2, zero) - 1) % mod) % mod;
    }
    cout << ans << endl;
  }
  return 0;
}
