// Arup Guha
// 7/27/2022
// Solution to 2022 March USACO Silver Problem: COW Operations

import java.util.*;
import java.io.*;

public class cowops {
	
	public static void main(String[] args) throws Exception {

		// Get data.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		char[] s = stdin.readLine().toCharArray();
		int n = s.length;
		
		// Calculate 3 cumulative frequency arrays so we can quickly count the numbers of C, O, Ws
		// in any range.
		int[] nC = new int[n+1];
		int[] nO = new int[n+1];
		int[] nW = new int[n+1];
		for (int i=0; i<n; i++) {
			if (s[i] == 'C') nC[i+1] = 1;
			if (s[i] == 'O') nO[i+1] = 1;
			if (s[i] == 'W') nW[i+1] = 1;
		}
		for (int i=1; i<=n; i++) {
			nC[i] += nC[i-1];
			nO[i] += nO[i-1];
			nW[i] += nW[i-1];
		}
		
		int nQ = Integer.parseInt(stdin.readLine());
		
		char[] res = new char[nQ];
		
		// Process queries.
		for (int i=0; i<nQ; i++) {
		
			// Get query, offset for cumulative frequency.
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			int sQ = Integer.parseInt(tok.nextToken()) - 1;
			int eQ = Integer.parseInt(tok.nextToken());
			
			// We just care about the parity.
			int cP = (nC[eQ]-nC[sQ])%2;
			int oP = (nO[eQ]-nO[sQ])%2;
			int wP = (nW[eQ]-nW[sQ])%2;
			
			/*** The key is that both operations keep the relative parity of C's to O's and W's
			     the same. When we delete 2 of the same, all 3 letters keep the same parity.
				 When we swap one letter for the other two, all 3 letters change their parity.
				 Since we want to end with one C and nothing else, the parity of C and O must be
				 opposite and the parity of C and W must be opposite.
			***/
			
			// This is how the parity has to be.
			if (cP != oP && cP != wP)
				res[i] = 'Y';
			else
				res[i] = 'N';
		}
		
		// Ta da!
		System.out.println(new String(res));
	}
}
