#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e5 + 10;
const ll inf = 1e18 + 10;
const ll MOD = 1e9 + 7;
ll n, q, cum[N];
ll add(ll x, ll y) { return (x + y) % MOD; }
ll mult(ll a, ll b) {
  ll res = a * b;
  res = res % MOD;
  return res;
}
ll binpow(ll a, ll b, ll m) {
  a %= m;
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
ll d(ll x, ll y) { return mult(x, binpow(y, MOD - 2, MOD)); }
ll subtract(ll x, ll y) {
  ll res = x - y;
  if (res < 0) res += MOD;
  return res;
}
int main() {
  cin >> n >> q;
  string s;
  cin >> s;
  for (ll i = 1; i <= n; i++) {
    cum[i] = cum[i - 1] + s[i - 1] - '0';
  }
  while (q--) {
    ll l, r;
    cin >> l >> r;
    ll one = cum[r] - cum[l - 1];
    ll zero = r - l + 1 - one;
    ll ans = mult(subtract(binpow(2, one, MOD), 1), binpow(2, zero, MOD));
    printf("%d\n", ans);
  }
  return 0;
}
