Problem: JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.

First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he defines the deliciousness of the part as x_i ∈ \{0, 1\}. JATC's going to eat those parts one by one. At each step, he chooses arbitrary remaining part and eats it. Suppose that part is the i-th part then his enjoyment of the Banh-mi will increase by x_i and the deliciousness of all the remaining parts will also increase by x_i. The initial enjoyment of JATC is equal to 0.

For example, suppose the deliciousness of 3 parts are [0, 1, 0]. If JATC eats the second part then his enjoyment will become 1 and the deliciousness of remaining parts will become [1, \\_, 1]. Next, if he eats the first part then his enjoyment will become 2 and the remaining parts will become [\\_, \\_, 2]. After eating the last part, JATC's enjoyment will become 4.

However, JATC doesn't want to eat all the parts but to save some for later. He gives you q queries, each of them consisting of two integers l_i and r_i. For each query, you have to let him know what is the maximum enjoyment he can get if he eats all the parts with indices in the range [l_i, r_i] in some order.

All the queries are independent of each other. Since the answer to the query could be very large, print it modulo 10^9+7.

Input

The first line contains two integers n and q (1 ≤ n, q ≤ 100 000).

The second line contains a string of n characters, each character is either '0' or '1'. The i-th character defines the deliciousness of the i-th part.

Each of the following q lines contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — the segment of the corresponding query.

Output

Print q lines, where i-th of them contains a single integer — the answer to the i-th query modulo 10^9 + 7.

Examples

Input

4 2
1011
1 4
3 4


Output

14
3


Input

3 2
111
1 2
3 3


Output

3
1

Note

In the first example: 

  * For query 1: One of the best ways for JATC to eats those parts is in this order: 1, 4, 3, 2. 
  * For query 2: Both 3, 4 and 4, 3 ordering give the same answer. 



In the second example, any order of eating parts leads to the same answer.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int dx4[] = {0, 0, -1, 1};
int dy4[] = {-1, 1, 0, 0};
int dx8[] = {0, 0, -1, 1, -1, -1, 1, 1};
int dy8[] = {-1, 1, 0, 0, -1, 1, -1, 1};
int knightx[] = {-1, 1, -2, 2, -2, 2, -1, 1};
int knighty[] = {-2, -2, -1, -1, 1, 1, 2, 2};
template <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    if (ch < '0' || ch > '9') break;
    n = n * 10 + (ch - '0');
    ch = getchar();
  }
  return (ng ? -n : n);
}
template <typename T>
inline T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
inline T Gcd(T a, T b) {
  if (a < 0) return Gcd(-a, b);
  if (b < 0) return Gcd(a, -b);
  return (b == 0) ? a : Gcd(b, a % b);
}
template <typename T>
inline T Lcm(T a, T b) {
  if (a < 0) return Lcm(-a, b);
  if (b < 0) return Lcm(a, -b);
  return a * (b / Gcd(a, b));
}
template <typename T>
T Bigmod(T base, T power, T MOD) {
  T ret = T(1) % MOD;
  while (power) {
    if (power & 1) ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
template <typename T>
long long isLeft(T a, T b, T c) {
  return (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y);
}
template <typename T>
T ModInverse(T number, T MOD) {
  return Bigmod(number, MOD - T(2), MOD);
}
bool isConst(char ch) {
  if (isalpha(ch) && !isVowel(ch)) return true;
  return false;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
bool isPrime(long long val) {
  if (val == 2) return true;
  if (val % 2 == 0 || val == 1) return false;
  long long sqrt_N = (long long)((double)sqrt(val));
  for (long long i = 3; i <= sqrt_N; i += 2) {
    if (val % i == 0) return false;
  }
  return true;
}
template <class T>
string convert(T _input) {
  stringstream blah;
  blah << _input;
  return blah.str();
}
bool valid(int r, int c, int x, int y) {
  if (x >= 1 && x <= r && y >= 1 && y <= c) return 1;
  return 0;
}
map<string, long long> month;
void Month() {
  month["January"] = 1, month["February"] = 2, month["March"] = 3,
  month["April"] = 4, month["May"] = 5, month["June"] = 6;
  month["July"] = 7, month["August"] = 8, month["September"] = 9,
  month["October"] = 10, month["November"] = 11, month["December"] = 12;
}
bool Check(int val, int pos) { return bool(val & (1 << pos)); }
int Set(int val, int pos) { return val | (1 << pos); }
int Reset(int val, int pos) { return val & (~(1 << pos)); }
int Flip(int val, int pos) { return val ^ (1 << pos); }
const long long maxn = 1e5 + 5;
long long n, m, caseno;
vector<long long> tree[4 * maxn];
long long a[maxn];
void init(long long node, long long left, long long right) {
  if (left == right) {
    tree[node].push_back(a[left]);
    return;
  }
  long long mid = left + ((right - left) >> 1);
  long long Lnode = (node << 1);
  long long Rnode = (node << 1) + 1;
  init(Lnode, left, mid);
  init(Rnode, mid + 1, right);
  merge(tree[Lnode].begin(), tree[Lnode].end(), tree[Rnode].begin(),
        tree[Rnode].end(), back_inserter(tree[node]));
}
long long query(long long node, long long left, long long right, long long i,
                long long j, long long val) {
  if (left > j || right < i) return 0;
  if (left >= i && right <= j) {
    return lower_bound(tree[node].begin(), tree[node].end(), val + 1LL) -
           tree[node].begin();
  }
  long long mid = left + ((right - left) >> 1);
  long long Lnode = (node << 1);
  long long Rnode = (node << 1) + 1;
  return query(Lnode, left, mid, i, j, val) +
         query(Rnode, mid + 1, right, i, j, val);
}
long long Fun(long long L, long long R, long long k) {
  long long left = -1000000000LL, right = 1000000000LL, mid, res;
  while (left <= right) {
    mid = left + ((right - left) >> 1);
    long long koyta = query(1, 1, n, L, R, mid);
    if (koyta >= k) {
      res = mid;
      right = mid - 1;
    } else
      left = mid + 1;
  }
  return res;
}
bool prm[1000007];
long long N = 1000000;
void sieve() {
  prm[0] = 1;
  for (long long i = 2; i <= N; i++) prm[i] = 0;
  for (long long i = 3; i * i <= N; i += 2) {
    if (prm[i >> 1] == 0) {
      for (long long j = i * i; j <= N; j += (i << 1)) {
        prm[j >> 1] = 1;
      }
    }
  }
}
long long Factor[100005], Sz;
long long cnt[100005], Mx;
long long Pre[100005];
long long Pre1[100005];
void PrimeFactorize(long long val) {
  long long i;
  if (val % 2 == 0) {
    Sz++;
    Factor[Sz] = 2;
    long long tot = 0;
    while (val % 2 == 0) {
      val /= 2;
      tot++;
    }
    cnt[2] = tot;
    Mx = max(Mx, tot);
  }
  for (i = 3; i <= sqrt(val); i += 2) {
    if (val % i == 0) {
      Sz++;
      Factor[Sz] = i;
      long long tot = 0;
      while (val % i == 0) {
        val /= i;
        tot++;
      }
      cnt[i] = tot;
      Mx = max(Mx, tot);
    }
  }
  if (val > 2) {
    Sz++;
    Factor[Sz] = val;
    cnt[val] = 1;
  }
}
char s[100005];
int main() {
  long long i, j, q;
  n = in<long long>(), q = in<long long>();
  scanf("%s", &s);
  for (i = n; i >= 1; i--) s[i] = s[i - 1];
  for (i = 1; i <= n; i++) {
    cnt[i] = s[i] - 48;
  }
  for (i = 1; i <= n; i++) {
    cnt[i] += cnt[i - 1];
  }
  long long d = 1;
  for (i = 1; i <= n; i++) {
    Pre[i] = (Pre[i - 1] + d) % 1000000007LL;
    Pre1[i] = (Pre1[i - 1] + d * i) % 1000000007LL;
    d *= 2;
    d %= 1000000007LL;
  }
  for (i = 1; i <= q; i++) {
    long long l, r;
    l = in<long long>(), r = in<long long>();
    long long m = r - l + 1;
    long long d = cnt[r] - cnt[l - 1];
    long long d1 = m - d;
    long long res = 0;
    if (d) {
      res = (d + d * (Pre[m - 1])) % 1000000007LL;
      res -= ((Bigmod(2LL, d1, 1000000007LL) * Pre1[d - 1])) % 1000000007LL;
      res %= 1000000007LL;
      res += 1000000007LL;
      res %= 1000000007LL;
    }
    printf("%lld\n", res);
  }
  return 0;
}