#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const int mod = 1e9 + 7;
inline pair<long long, long long> mp(long long a, long long b) {
  pair<long long, long long> temp;
  temp.first = a;
  temp.second = b;
  return temp;
}
long long read_int() {
  char r;
  bool start = false, neg = false;
  long long ret = 0;
  while (true) {
    r = getchar();
    if ((r - '0' < 0 || r - '0' > 9) && r != '-' && !start) {
      continue;
    }
    if ((r - '0' < 0 || r - '0' > 9) && r != '-' && start) {
      break;
    }
    if (start) ret *= 10;
    start = true;
    if (r == '-')
      neg = true;
    else
      ret += r - '0';
  }
  if (!neg)
    return ret;
  else
    return -ret;
}
long long p[N][2], comp[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, q;
  cin >> n >> q;
  string st;
  cin >> st;
  p[0][0] = p[0][1] = 0;
  for (long long i = 0; i < st.size(); i++) {
    if (i != 0) {
      p[i][0] = p[i - 1][0];
      p[i][1] = p[i - 1][1];
    }
    long long cur = st[i] - '0';
    p[i][cur]++;
  }
  comp[0] = 1;
  for (long long i = 1; i < N; i++) {
    comp[i] = comp[i - 1] * 2;
    comp[i] %= mod;
  }
  while (q--) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    long long c0;
    if (l == 0)
      c0 = p[r][0];
    else
      c0 = p[r][0] - p[l - 1][0];
    long long ans = comp[r - l + 1] - comp[c0];
    ans += mod;
    ans %= mod;
    cout << ans << endl;
  }
}
