Problem1469--0-1 sequence

1469: 0-1 sequence

Time Limit: 4 Sec  Memory Limit: 128 MB
Submit: 6  Solved: 3
[Submit] [Status] [Web Board] [Creator:]

Description

There is a sequence of 0 and 1.
Let the length of the sequence be N, and if each element of the sequence is numbered sequentially, the first number will be 0, the second number will be 1, and the last number will be N-1.
Let's randomly select two numbers i and j that are greater than or equal to 0 and less than or equal to N-1, and find the maximum and minimum values among the numbers from the i-th to the j-th, and see if the two values are same.

Input

The first line contains a sequence of numbers with a maximum length of 1,000,000. There are no spaces between the numbers.
The next line contains an integer N (N<=100,000) indicating the number of questions.
From the next line, two numbers indicating the corresponding section i and j are entered in N lines.

Output

For each question, if the maximum and minimum values of the corresponding sections i and j are the same, print Yes; otherwise, print No.

Sample Input Copy

0000011111
3
0 5
4 2
5 9

Sample Output Copy

No
Yes
Yes

Source/Category