1.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
* Angewandte Mathematik, SS11
* Problem: 10324 Zeros and Ones
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=15&page=show_problem&problem=1265
*
* @author Benedikt Zšnnchen
* @author Erik Wenzel
* @version 1.0, 12/04/2011
*
* Method : Ad-hoc
* Status : Accepted
* Runtime: 1.700
*/

public class Main
{
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String content;
int counter = 1;
while((content=reader.readLine()) != null)
{
//System.out.println(content);
if(content.split(" ").length == 2)
{
break;
}
System.out.println("Case "+counter+":");

int cases = Integer.parseInt(reader.readLine());
for(int i=1; i<=cases; i++)
{
String[] numbers = reader.readLine().split(" ");
int n1 = Integer.parseInt(numbers[0]);
int n2;

if(numbers.length<2)
{
n2 = n1;
}
else
{
//System.out.println("WTF");
n2 = Integer.parseInt(numbers[1]);
}

String subString = content.substring(Math.min(n1,n2), Math.max(n1, n2)+1);
//System.out.println(subString);
if(subString.contains("0") && subString.contains("1"))
{
System.out.println("No");
}
else
{
System.out.println("Yes");
}
}
counter++;
}

}
}