You are given a string containing only lowercase alphabet characters. You are also given queries. In each query, you are given two integers and . Consider a substring of string . You are required to print the number of permutations of the substring that are lexicographically smallest among all permutations of . Since the number can be very large, print it modulo .
Input format
Output format
For each test case, print the number of permutations for each query in the next lines.
Constraints
For the first query, the lexicographically smallest substring is "bb", therefore, the number of permutations are only 2 ({1,2} and {2,1}).
For the second query, the lexicographically smallest substring is "aabb", therefore, the number of permutations are 4 ({1,2,3,4}, {1,2,4,3}, {2,1,3,4} and {2,1,4,3}).