#include <bits/stdc++.h>
using namespace std;
long long m0 = 0, m1 = 0;
vector<long long> v0, v1, v2;
int main() {
  long long q, n, i, j, cnt = 0, l, r, one = 0, zero = 0, even = 0, odd = 0,
                        total = 0;
  string s;
  cin >> n >> q;
  cin >> s;
  v0.push_back(0);
  v1.push_back(0);
  long long p = 1;
  for (i = 0; i <= 100005; i++) {
    v2.push_back(p);
    p = (p * 2) % 1000000007;
  }
  for (i = 0; i < n; i++) {
    if (s[i] == '0')
      m0++;
    else
      m1++;
    v0.push_back(m0);
    v1.push_back(m1);
  }
  while (q--) {
    cin >> l >> r;
    one = v1[r] - v1[l - 1];
    zero = v0[r] - v0[l - 1];
    even = (v2[one] - 1) % 1000000007;
    long long qq = (v2[zero] - 1) % 1000000007;
    odd = (even * qq) % 1000000007;
    total = (even + odd) % 1000000007;
    cout << total << endl;
  }
}
