#include <bits/stdc++.h>
using namespace std;
long long n, q, a[100005], b[100005], l, r, _2[100005];
char s[100005];
int main() {
  _2[0] = 1;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) _2[i] = _2[i - 1] * 2 % 1000000007;
  scanf("%s", s);
  a[0] = b[0] = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1] + (s[i - 1] == '1');
    b[i] = b[i - 1] + (s[i - 1] == '0');
  }
  while (q--) {
    scanf("%lld%lld", &l, &r);
    int x = a[r] - a[l - 1], y = b[r] - b[l - 1];
    printf("%lld\n", (_2[x] - 1 + 1000000007) * _2[y] % 1000000007);
  }
  return 0;
}
