#include <bits/stdc++.h>
using namespace std;
long long N, Q, S[(int)1e5 + 5], i, L, R, p1, p2;
long long Putere(long long p1, long long ex) {
  long long i, sol = 1;
  for (i = 0; (1 << i) <= ex; i++) {
    if (((1 << i) & ex) > 0) sol = (sol * p1) % 1000000007;
    p1 = (p1 * p1) % 1000000007;
  }
  return sol;
}
string str;
int main() {
  cin >> N >> Q;
  cin >> str;
  for (i = 0; i < str.length(); i++) {
    if (str[i] == '1')
      S[i + 1] = S[i] + 1;
    else
      S[i + 1] = S[i];
  }
  while (Q--) {
    cin >> L >> R;
    p1 = S[R] - S[L - 1];
    p2 = R - L + 1 - p1;
    cout << ((Putere(2, p1) - 1 + (Putere(2, p1) - 1) * (Putere(2, p2) - 1))) %
                1000000007
         << "\n";
  }
  return 0;
}
