Joey Tribbiani

3.5

2 votes
Easy
Problem

Joey Tribbiani

enter image description here

Joey, who calls himself as "actor-slash-model" has not been doing so well in the movies lately. The movie director these days are asking a lot of questions to Joey before signing him up.

After many auditions he is at last step for getting the role he has been desiring for Dr. Drake Ramoray. But knowing him as he is, He asks for your help to help him land the chance for his lifetime by solving this challenging problem ( challenging for Joey, its cakewalk for you guys).

The director is crazy for palindromes and loves to make them a lot. He first gives to Joey the name of a movies S which is more often than not a long one for testing Joeys speed, and then asks him Q queries of the form [L R]. For each query joey is supposed to tell whether or not he will be able to make a palindrome of the substring by just rearranging the letters of the movie name from L to R.

Can you Help ?

Input:

The first line of input contain a string S, of lowercase characters.
Next line contains an integer Q - number of queries.
Each of the next Q lines contain two integers L R.

Output:

For each query output 'Yes' or 'No'.

Constraints:

Problem Setter - Saurabh

Sample Input
aabbcdc
2
1 4
5 6
Sample Output
Yes
No
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For query 1- In the given input index 1 to 4 consists of 'aabb' , which can be rearranged to abba, therefore Yes.

For query 2- Index 5 to 6 is 'cd', which can not be rearranged to a palindrome.

Editor Image

?