#include <bits/stdc++.h>
using namespace std;
long long l, r, n, q, p[200000], a[200000], k, m, mod = 1e9 + 7;
string s;
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < n; i++) {
    a[i + 1] += a[i];
    if (s[i] == '1') a[i + 1]++;
  }
  p[0] = 1;
  for (int i = 1; i <= 1e5; i++) p[i] = (p[i - 1] * 2) % mod;
  for (int i = 0; i < q; i++) {
    cin >> l >> r;
    cout << (p[r - l + 1] - p[r - l + 1 - a[r] + a[l - 1]] + mod) % mod << endl;
  }
  return 0;
}
