You are given a string s and several queries. For the i-th query, calculate the number of different palindromic substrings of s\[l_i..r_i]. A substring is called palindromic if it reads the same from right to left as from left to right. Two substrings are considered different if they differ as strings.
The first line contains a non-empty string s consisting of lowercase English letters. The length of the string does not exceed 105 characters.
The second line contains an integer q, the number of queries (1≤q≤105). Next q lines contain queries. Each of these lines contains integers l_i and r_i separated by a space (1≤l_i≤r_i≤∣s∣).
Output q lines. The i-th line must contain one integer: the answer to the i-th query.