#include <bits/stdc++.h>
using namespace std;
long long n, q, p[100005];
string s;
long long expo(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}
void solve() {
  cin >> n >> q;
  cin >> s;
  p[0] = s[0] == '1';
  for (long long i = 1; i < n; i++) {
    p[i] = (s[i] == '1') + p[i - 1];
  }
  while (q--) {
    long long l, r;
    cin >> l >> r;
    l--, r--;
    long long first = p[r] - (l ? p[l - 1] : 0);
    long long second = r - l + 1 - first;
    long long ans = (expo(2, first, 1000000007) - 1 + 1000000007) % 1000000007;
    ans = (ans * expo(2, second, 1000000007)) % 1000000007;
    cout << ans << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
