Menu Close

Read a word if it consists only of the letters known.

Not everyone probably knows that Nivin has younger brother Nithin. Currently Nithin learns to read.

He knows some subset of the letter of Latin alphabet. In order to help Nithin to study, Nivin gave him a book with the text consisting of N words. Nithin can read a word if it consists only of the letters he knows.

Now Nivin is curious about which words his brother will be able to read, and which are not. Please help him!

Input:
The first line of the input contains a lowercase Latin letter string S, consisting of the letters Nithin can read. 

The second line of the input contains an integer N denoting the number of words in the book.

Each of the following N lines contains a single lowecase Latin letter string Wi, denoting the ith word in the book

Output:
For each of the words, output "Yes" (without quotes) in case Nithin can read it, and "No" (without quotes) otherwise.
#include <stdio.h>
#include <string.h>
int main()
{
    char string[100];char search[100];
    int t,i,j,len,c=0;
    scanf("%s",string);
    len=strlen(string);
    scanf("%d",&t);
    while(t--){
        c=0;
        scanf("%s",search);
        for(i=0;i<=strlen(string)-1;i++)
        {
            for(j=0;j<=strlen(search)-1;j++)
            {
                if(string[i]==search[j]){
                c++;break;}
             }
         }
         if(c==len)
         printf("Yes\n");
         else
         printf("No\n");
}

	return 0;
}

INPUT_1:
mat
2
rat
vat

OUTPUT:
No
No


INPUT_2:
not
3
ton
ten
don

OUTPUT:
Yes
No
No


ILLUSTRATION

Executed using gcc

Morae Q!