#include<stdio.h>
#include<string.h>
int one=0,two=0,three=0,four=0,five=0,six=0;
pre(char dian[])
{
one=0;two=0;three=0;four=0;five=0;six=0;
for(int i=0;i<6;i++)
{
switch(dian[i]-'0')
{
case 1:
one++;
break;
case 2:
two++;
break;
case 3:
three++;
break;
case 4:
four++;
break;
case 5:
five++;
break;
case 6:
six++;
break;
}
}
}
int main()
{
int n;
scanf("%d",&n);
getchar();
int k;
for(k=0;k<n;k++)
{
int i,j,m;
char dian[6]={0};
for(i=0;i<6;i++)
{
scanf("%c",&dian[i]);
}
pre(dian);
scanf("%d",&m);
getchar();
for(i=0;i<m;i++)
{
int a,b;
scanf("%d %d",&a,&b);
getchar();
switch(b)
{
case 1:
if(one>=a)
{
printf("%d:true\n",i+1);
}
else
{
printf("%d:false\n",i+1);
}
break;
case 2:
if(two+one>=a)
{
printf("%d:true\n",i+1);
}
else
{
printf("%d:false\n",i+1);
}
break;
case 3:
if(three+one>=a)
{
printf("%d:true\n",i+1);
}
else
{
printf("%d:false\n",i+1);
}
break;
case 4:
if(four+one>=a)
{
printf("%d:true\n",i+1);
}
else
{
printf("%d:false\n",i+1);
}
break;
case 5:
if(five+one>=a)
{
printf("%d:true\n",i+1);
}
else
{
printf("%d:false\n",i+1);
}
break;
case 6:
if(six+one>=a)
{
printf("%d:true\n",i+1);
}
else
{
printf("%d:false\n",i+1);
}
break;
}
}
putchar('\n');
}
return 0;
}
|