Problem: There is a colony of villains with several holes aligned in a row, where each hole contains exactly one villain.

Each colony arrangement can be expressed as a string of even length, where the i-th character of the string represents the type of villain in the i-th hole. 

Iron Man can destroy a colony only if the colony arrangement is such that all villains of a certain type either live in the first half of the colony or in the second half of the colony.

His assistant Jarvis has a special power. It can swap villains of any two holes, i.e. swap any two characters in the string; he can do this operation any number of times.

Now Iron Man asks Jarvis q questions. In each question, he gives Jarvis two numbers x and y. Jarvis has to tell Iron Man the number of distinct colony arrangements he can create from the original one using his powers such that all villains having the same type as those originally living in x-th hole or y-th hole live in the same half and the Iron Man can destroy that colony arrangement.

Two colony arrangements are considered to be different if there exists a hole such that different types of villains are present in that hole in the arrangements.

Input

The first line contains a string s (2 ≤ |s| ≤ 10^{5}), representing the initial colony arrangement. String s can have both lowercase and uppercase English letters and its length is even.

The second line contains a single integer q (1 ≤ q ≤ 10^{5}) — the number of questions.

The i-th of the next q lines contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ |s|, x_i ≠ y_i) — the two numbers given to the Jarvis for the i-th question.

Output

For each question output the number of arrangements possible modulo 10^9+7.

Examples

Input


abba
2
1 4
1 2


Output


2
0


Input


AAaa
2
1 2
1 3


Output


2
0


Input


abcd
1
1 3


Output


8

Note

Consider the first example. For the first question, the possible arrangements are "aabb" and "bbaa", and for the second question, index 1 contains 'a' and index 2 contains 'b' and there is no valid arrangement in which all 'a' and 'b' are in the same half.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
const int N = 100005;
const int M = 1e9 + 7;
long long qpow(long long a, long long n, long long p) {
  long long r = 1;
  for (a %= p; n; n >>= 1, (a *= a) %= p)
    if (n & 1) (r *= a) %= p;
  return r;
}
int sz[52];
char s[N];
int get_chr(char c) {
  if (c >= 'A' && c <= 'Z')
    return c - 'A';
  else if (c >= 'a' && c <= 'z')
    return c - 'a' + 26;
}
long long fac[N], ans[52][52], dp0[N], dp1[N], dp2[N];
int main() {
  time_point<steady_clock> start = steady_clock::now();
  fac[0] = 1;
  for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % M;
  int n, q, x, y;
  scanf("%s%d", s, &q);
  n = strlen(s);
  for (int i = 0; i < n; i++) sz[get_chr(s[i])]++;
  long long X = fac[n / 2] * fac[n / 2] % M;
  for (int i = 0; i < 52; i++) (X *= qpow(fac[sz[i]], M - 2, M)) %= M;
  dp0[0] = 1;
  for (int i = 0; i < 52; i++)
    for (int j = n / 2; sz[i] && j >= sz[i]; j--)
      (dp0[j] += dp0[j - sz[i]]) %= M;
  long long Y = dp0[n / 2] * X % M;
  for (int c1 = 0; c1 < 52; c1++) {
    if (!sz[c1]) continue;
    ans[c1][c1] = Y;
    memcpy((dp1), (dp0), sizeof(dp0));
    for (int j = sz[c1]; j <= n / 2; j++)
      ((dp1[j] -= dp1[j - sz[c1]]) += M) %= M;
    for (int c2 = c1 + 1; c2 < 52; c2++) {
      if (!sz[c2]) continue;
      memcpy((dp2), (dp1), sizeof(dp1));
      for (int j = sz[c2]; j <= n / 2; j++)
        ((dp2[j] -= dp2[j - sz[c2]]) += M) %= M;
      ans[c1][c2] = ans[c2][c1] =
          (dp0[n / 2] -
           ((dp0[n / 2] - dp1[n / 2] + M) % M - dp2[n / 2] + M) * 2 % M + M) *
          X % M;
    }
  }
  while (q--) {
    scanf("%d%d", &x, &y);
    printf("%lld\n", ans[get_chr(s[x - 1])][get_chr(s[y - 1])]);
  }
  cerr << endl
       << "------------------------------" << endl
       << "Time: "
       << duration<double, milli>(steady_clock::now() - start).count() << " ms."
       << endl;
  return 0;
}