#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int MOD = 1000000007;
int N, Q;
char c[MAXN];
int S[MAXN];
long long modpow(long long base, long long expo) {
  base %= MOD;
  long long res = 1;
  while (expo > 0) {
    if (expo & 1) res = res * base % MOD;
    base = base * base % MOD;
    expo >>= 1;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  cin >> c + 1;
  for (int i = (1); i <= (N); i++) S[i] = S[i - 1] + (c[i] == '1');
  while (Q--) {
    int L, R;
    cin >> L >> R;
    long long a = S[R] - S[L - 1];
    long long b = (R - L + 1) - a;
    cout << (modpow(2, a) - 1 + MOD) % MOD * modpow(2, b) % MOD << "\n";
  }
}
