#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
long long mod_pow(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
signed main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<long long> csum1(n + 1, 0), csum0(n + 1, 0);
  for (long long i = 0; i < n; i++) {
    csum0[i + 1] = csum0[i];
    csum1[i + 1] = csum1[i];
    if (s[i] == '0') csum0[i + 1]++;
    if (s[i] == '1') csum1[i + 1]++;
  }
  for (long long i = 0; i < q; i++) {
    long long l, r;
    cin >> l >> r;
    long long ans = 0;
    long long cnt1 = csum1[r] - csum1[l - 1];
    long long cnt0 = csum0[r] - csum0[l - 1];
    ans += mod_pow(2, cnt1) - 1;
    ans %= MOD;
    ans += (mod_pow(2, cnt0) - 1) * (mod_pow(2, cnt1) - 1);
    ans %= MOD;
    cout << ans << endl;
  }
}
