Master Zhu and Palindromes
시간 제한2초메모리 제한512 MB
각 질의 구간 S[L..R]에서 꼬리가 주어진 문자열 T로 시작하는 회문 부분 문자열의 개수를 센다.
문제
Master Zhu has a string . This string can contain only the first five lowercase English letters. Another peculiar property of is that the length of each palindrome substring in is less than .
For a palindrome string , its tail is the string . For example, the tail of the string "aba" is "ba", and the tail of the string "caac" is "ac".
Given , , and a string , Master Zhu wants you to find the number of different palindrome substrings in such that is a prefix of their tails. Here, two substrings are considered different if their starting or ending positions in differ.
입력
The first line of input contains one integer , the number of test cases ().
The first line of each test case contains a string consisting only of the first five lowercase English letters (, the length of each palindrome substring in is less than ).
The second line contains one integer , the number of queries (). Each of the next lines contains two integers and and a string consisting only of the first five lowercase English letters (, ).
출력
For each query, print a single line with a single integer: the number of different palindrome substrings in such that is a prefix of their tails.