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;
const int mod = 1e9 + 7;
long long jie[100000 + 100];
long long inv[100000 + 100];
long long poww(long long a, long long b) {
  long long base = a;
  long long res = 1;
  while (b) {
    if (b & 1) {
      res *= base;
      res %= mod;
    }
    base *= base;
    base %= mod;
    b >>= 1;
  }
  return res;
}
void init() {
  jie[1] = 1;
  jie[0] = 1;
  inv[0] = 1;
  inv[1] = 1;
  for (int i = 2; i <= 100000 + 50; i++) {
    jie[i] = jie[i - 1] * i % mod;
    inv[i] = poww(jie[i], mod - 2);
  }
}
char s[100000 + 100];
int cnt[60];
long long dp[50000 + 100];
long long d2p[50000 + 100];
long long ans[60][60];
int main() {
  init();
  scanf("%s", s);
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    if ('a' <= s[i] && s[i] <= 'z') {
      cnt[s[i] - 'a']++;
    } else
      cnt[s[i] - 'A' + 26]++;
  }
  memset(dp, 0, sizeof dp);
  dp[0] = 1;
  for (int i = 0; i < 52; i++) {
    if (cnt[i]) {
      for (int j = len / 2; j >= cnt[i]; j--) {
        if (dp[j - cnt[i]] != 0) {
          dp[j] = (dp[j] + dp[j - cnt[i]]) % mod;
        }
      }
    }
  }
  for (int x = 0; x < 52; x++) {
    for (int y = 0; y < 52; y++) {
      if (x == y) continue;
      if (!(cnt[x] && cnt[y])) continue;
      for (int j = 0; j <= len / 2; j++) d2p[j] = dp[j];
      for (int j = cnt[x]; j <= len / 2; j++) {
        d2p[j] = ((d2p[j] - d2p[j - cnt[x]]) + mod) % mod;
      }
      for (int j = cnt[y]; j <= len / 2; j++) {
        d2p[j] = ((d2p[j] - d2p[j - cnt[y]]) + mod) % mod;
      }
      ans[x][y] = d2p[len / 2];
    }
  }
  int q;
  scanf("%d", &q);
  long long root = jie[len / 2] * jie[len / 2] % mod;
  for (int i = 0; i < 52; i++) {
    if (cnt[i]) root = root * inv[cnt[i]] % mod;
  }
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    char t1 = s[x];
    char t2 = s[y];
    int num1, num2;
    if ('a' <= t1 && t1 <= 'z') {
      num1 = t1 - 'a';
    } else
      num1 = t1 - 'A' + 26;
    if ('a' <= t2 && t2 <= 'z') {
      num2 = t2 - 'a';
    } else
      num2 = t2 - 'A' + 26;
    long long res = 0;
    if (num1 == num2) {
      res = dp[len / 2] * root % mod;
    } else {
      res = root * ans[num1][num2] % mod * 2 % mod;
    }
    printf("%d\n", res);
  }
}