#include <bits/stdc++.h>
using namespace std;
long long int max2 = 1000000007;
long long int power(long long int base, long long int exp) {
  long long int ans = 1;
  while (exp) {
    if (exp % 2 == 1) {
      ans *= base;
      ans %= max2;
    }
    exp /= 2;
    base *= base;
    base %= max2;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
  int tab;
  auto geti = [&]() {
    cin >> tab;
    return tab;
  };
  ;
  long long int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  long long int onescount[n];
  if (s[0] == '0') {
    onescount[0] = 0;
  } else {
    onescount[0] = 1;
  }
  for (long long int i = 1; i < n; i++) {
    if (s[i] == '0') {
      onescount[i] = onescount[i - 1];
    } else {
      onescount[i] = onescount[i - 1] + 1;
    }
  }
  while (q > 0) {
    long long int l, r;
    cin >> l >> r;
    l--;
    r--;
    long long int one = onescount[r] - onescount[l];
    long long int zero = 0;
    if (s[l] == '1' && s[l] == '1') {
      one++;
    } else if (s[l] == '1' && s[r] == '0') {
      one++;
    }
    zero = r - l + 1 - one;
    long long int count = 0;
    long long int a = power(2, one) - 1;
    long long int b = power(2, zero);
    count = (a * b) % max2;
    cout << count << endl;
    q--;
  }
  return 0;
}
