#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
int s0[100005];
long long qpow(long long x, int n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % int(1e9 + 7);
    x = x * x % int(1e9 + 7);
    n /= 2;
  }
  return res;
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < N; i++) {
    s0[i + 1] = s0[i] + (s[i] == '0');
  }
  int l, r;
  while (Q--) {
    cin >> l >> r;
    long long ans =
        (qpow(2, r - l + 1) - qpow(2, s0[r] - s0[l - 1]) + int(1e9 + 7)) %
        int(1e9 + 7);
    cout << ans << endl;
  }
  return 0;
}
