#include <bits/stdc++.h>
using namespace std;
void no() { cout << "NO\n"; }
void yes() { cout << "YES\n"; }
long long int pow_(long long int a, long long int n) {
  if (n == 0) return 1;
  if (n == 1) return a;
  if (n % 2 == 0)
    return ((pow_(a, n / 2) % 1000000007) * (pow_(a, n / 2) % 1000000007)) %
           1000000007;
  else
    return ((((pow_(a, n / 2) % 1000000007) * (pow_(a, n / 2) % 1000000007)) %
             1000000007) *
            (a % 1000000007)) %
           1000000007;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, q;
  string s;
  cin >> n >> q >> s;
  long long int o = 0;
  long long int z = 0;
  vector<pair<long long int, long long int> > v(n + 1);
  v[0] = make_pair(0, 0);
  for (long long int i = 0; i < n; i += 1) {
    if (s[i] == '1') o++;
    if (s[i] == '0') z++;
    v[i + 1] = make_pair(o, z);
  }
  for (long long int i = 0; i < q; i += 1) {
    long long int l, r;
    cin >> l >> r;
    long long int len = r - l + 1, ones = v[r].first - v[l - 1].first;
    long long int a = pow_(2, len - ones) % 1000000007,
                  b = ((pow_(2, ones) % 1000000007) - (1 % 1000000007)) %
                      1000000007;
    if (b < 0) b += 1000000007;
    cout << ((a % 1000000007) * (b % 1000000007)) % 1000000007 << "\n";
  }
  return 0;
}
