#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MAXN = 5 + 100000;
constexpr int MOD = 7 + 1000000000;
int oac[MAXN];
int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}
int sub(int a, int b) {
  int ans = a - b;
  if (ans < 0) ans += MOD;
  return ans;
}
int mul(int a, int b) { return (int)((1LL * a * b) % MOD); }
int fpow(int b, int e) {
  int ans = 1, p = b;
  for (; e; e >>= 1) {
    if (e & 1) ans = mul(ans, p);
    p = mul(p, p);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string s;
  int n, q;
  cin >> n >> q >> s;
  for (int i = (int)0; i < (int)n; ++i) {
    oac[i] = (s[i] == '1');
    if (i >= 1) oac[i] += oac[i - 1];
  }
  while (q--) {
    int first, second;
    cin >> first >> second;
    --first;
    --second;
    int o = oac[second];
    if (first >= 1) o -= oac[first - 1];
    if (o == 0) {
      cout << 0 << '\n';
    } else {
      int sum1 = sub(fpow(2, o), 1);
      int sum2 = mul(sum1, sub(fpow(2, 1 + second - first - o), 1));
      cout << add(sum1, sum2) << '\n';
    }
  }
  return 0;
}
