#include <bits/stdc++.h>
using namespace std;
char a[100001];
int len[100001];
long long quick_pow(long long a, int b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int main() {
  int n, q;
  while (scanf("%d%d", &n, &q) != EOF) {
    memset(len, 0, sizeof(len));
    scanf("%s", a);
    if (a[0] == '0') len[0]++;
    for (int i = 1; i < n; i++)
      if (a[i] == '0')
        len[i] = len[i - 1] + 1;
      else
        len[i] = len[i - 1];
    while (q--) {
      int l, r;
      scanf("%d%d", &l, &r);
      int x;
      if (l >= 2)
        x = len[r - 1] - len[l - 2];
      else
        x = len[r - 1];
      long long re = (((quick_pow(2, r - l + 1 - x) - 1) % 1000000007) *
                      (quick_pow(2, x) % 1000000007) % 1000000007);
      printf("%lld\n", re);
    }
  }
  return 0;
}
