#include <bits/stdc++.h>
#pragma GCC optimize("03")
using namespace std;
long long int const mod = 1e9 + 7;
long long int pre[100010][2];
void mul(long long int &x, long long int val) {
  x = (x * val) % mod;
  if (x < 0) x += mod;
}
void add(long long int &x, long long int val) {
  x = (x + val) % mod;
  if (x < 0) x += mod;
}
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1ll) mul(res, x);
    mul(x, x);
    y >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, q, l, r, one, zero, x, y, val, d;
  string st;
  cin >> n >> q;
  cin >> st;
  for (long long int i = 1; i <= n; i++) {
    d = st[i - 1] - '0';
    pre[i][d] += 1;
  }
  for (long long int i = 1; i <= n; i++) {
    pre[i][0] += pre[i - 1][0];
    pre[i][1] += pre[i - 1][1];
  }
  while (q--) {
    cin >> l >> r;
    one = pre[r][1] - pre[l - 1][1];
    zero = pre[r][0] - pre[l - 1][0];
    if (one) {
      x = (power(2, one) - 1);
      val = x;
      y = (power(2, zero) - 1);
      mul(y, val);
      add(x, y);
      cout << x << "\n";
    } else {
      y = 0;
      cout << y << "\n";
    }
  }
  return 0;
}
