Problem:
Score : 1300 points

Problem Statement

You are developing a robot that processes strings.
When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below:

Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure.

If t_i is z, remove t_i and t_{i + 1} from t. Otherwise, let c be the next letter of t_i in the English alphabet, and replace t_i and t_{i + 1} together with c, reducing the length of t by 1.

Go back to step 1.

For example, when the robot is given the string axxxxza, it will be processed as follows: axxxxza → ayxxza → ayyza → azza → aa → b.

You are given a string s consisting of lowercase English letters.
Answer Q queries. The i-th query is as follows:

Assume that the robot is given a substring of s that runs from the l_i-th character and up to the r_i-th character (inclusive). Will the string be empty after processing?

Constraints

1 ≤ |s| ≤ 5 × 10^5

s consists of lowercase English letters.

1 ≤ Q ≤ 10^5

1 ≤ l_i ≤ r_i ≤ |s|

Input

The input is given from Standard Input in the following format:

s
Q
l_1 r_1
l_2 r_2
:
l_Q r_Q

Output

Print Q lines.
The i-th line should contain the answer to the i-th query: Yes or No.

Sample Input 1

axxxxza
2
1 7
2 6

Sample Output 1

No
Yes

Regarding the first query, the string will be processed as follows: axxxxza → ayxxza → ayyza → azza → aa → b.

Regarding the second query, the string will be processed as follows: xxxxz → yxxz → yyz → zz → .

Sample Input 2

aabcdefghijklmnopqrstuvwxyz
1
1 27

Sample Output 2

Yes

Sample Input 3

yzyyyzyzyyyz
8
1 6
7 12
1 12
6 11
1 1
1 3
4 9
3 8

Sample Output 3

Yes
Yes
Yes
Yes
No
No
No
No

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System.IO;
using System.Linq;
using System;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(Console.ReadLine());
	int[] G() => Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		var S = Console.ReadLine();
		var N = S.Length;
		var e = 26;
		var next = new int[N + 1, e + 1];
		for (var c = 0; c <= e; c++) next[N + 1, c] = next[N, c] = N + 1;
		for (var i = N - 1; i >= 0; i--)
		{
			var x = S[i] - 'a';
			next[i, x] = i + 1;
			for (var c = x + 1; c <= e; c++) next[i, c] = next[next[i, c - 1], c - 1];
			if (x != 0) next[i, 0] = next[next[i, e], 0];
			for (var c = 1; c < x; c++) next[i, c] = next[next[i, c - 1], c - 1];
			for (var c = 1; c < x; c++) next[i, c] = Math.Min(next[i, c], next[next[i, e], c]);
		}
		var log = 2;
		while ((1 << log) <= N + 3) log++;
		var dp = new int[N + 2, log];
		for (var i = 0; i < N + 2; i++) dp[i, 0] = next[i, e];
		for (var p = 1; p < log; p++) for (var i = 0; i < N + 2; i++) dp[i, p] = dp[dp[i, p - 1], p - 1];
		var Q = F();
		for (var q = 0; q < Q; q++)
		{
			var I = G();
			var l = I[0] - 1;
			var r = I[1];
			for (var i = log - 1; i >= 0; i--) if (dp[l, i] <= r) l = dp[l, i];
			Console.WriteLine(l == r ? "Yes" : "No");
		}
		Console.Out.Flush();
	}
}