Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. 

Not everyone probably knows that Chef has younger brother Jeff. Currently Jeff learns to read.

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

Now Chef 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 Jeff can read. Every letter will appear in S no more than once.

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 W_{i}, denoting the i^{th} word in the book.

------ Output ------ 

For each of the words, output "Yes" (without quotes) in case Jeff can read it, and "No" (without quotes) otherwise.

------ Constraints ------ 

$1 ≤ |S| ≤ 26$
$1 ≤ N ≤ 1000$
$1 ≤ |W_{i}| ≤ 12$
$Each letter will appear in S no more than once.$
$S, W_{i} consist only of lowercase Latin letters.$

------ Subtasks ------ 

$Subtask #1 (31 point): |S| = 1, i.e. Jeff knows only one letter.$
$Subtask #2 (69 point)	: no additional constraints$

----- Sample Input 1 ------ 
act
2
cat
dog
----- Sample Output 1 ------ 
Yes
No
----- explanation 1 ------ 
The first word can be read.
The second word contains the letters d, o and g that aren't known by Jeff.

Difficulty: EASY
Tags: String algorithms

Data structures

Implementation

Complete search
Skill types: Data structures

Complete search

Starter code:

Solutions:
s = input()
n = int(input())
for i in range(n):
	word = input()
	for l in word:
		if not l in s:
			print('No')
			break
	else:
		print('Yes')


s = input()
n = int(input())
for _ in range(n):
	w = input()
	if all(map(lambda x: x in s, w)):
		print('Yes')
	else:
		print('No')


s = input()
n = int(input())
for w in range(n):
	word = input().rstrip()
	for l in word:
		if not l in s:
			print('No')
			break
	else:
		print('Yes')


s = input()
t = int(input())
for i in range(t):
	a = input()
	count = 0
	for i in a:
		if i not in s:
			print('No')
			break
		else:
			count += 1
	if count == len(a):
		print('Yes')


s = input()
n = int(input())
for i in range(n):
	ss = input()
	for i in ss:
		if i not in s:
			print('No')
			break
	else:
		print('Yes')


def can_read(word, letters):
	for letter in word:
		if letter not in letters:
			return False
	return True
letters = input().strip()
n = int(input())
words = [input().strip() for i in range(n)]
for word in words:
	if can_read(word, letters):
		print('Yes')
	else:
		print('No')


stringOne = input()
num = int(input())
for i in range(num):
	take = input()
	YN = True
	for j in take:
		if j in stringOne:
			continue
		else:
			YN = False
			break
	if YN == True:
		print('Yes')
	else:
		print('No')


Saurav = str(input())
Ranjan = int(input())
for _ in range(Ranjan):
	W = str(input())
	for i in W:
		if i not in Saurav:
			print('No')
			break
	else:
		print('Yes')


S = str(input())
N = int(input())
for _ in range(N):
	W = str(input())
	for i in W:
		if i not in S:
			print('No')
			break
	else:
		print('Yes')


n = input()
n1 = int(input())
for i in range(n1):
	a = input()
	for l in a:
		if not l in n:
			print('No')
			break
	else:
		print('Yes')


S = input()
N = int(input())
for i in range(N):
	w = input()
	for i in w:
		if i not in S:
			print('No')
			break
	else:
		print('Yes')


k = input()
for _ in range(int(input())):
	a = input()
	if all(map(lambda x: x in k, a)):
		print('Yes')
	else:
		print('No')


s = str(input())
n = int(input())
for i in range(n):
	w = str(input())
	cek = 0
	for i in w:
		if i in s:
			cek = 1
		else:
			cek = 0
			break
	if cek == 1:
		print('Yes')
	else:
		print('No')


r = input()
t = int(input())
for _ in range(t):
	count = 0
	s = input()
	for i in range(len(s)):
		if s[i] in r:
			count += 1
	if count == len(s):
		print('Yes')
	else:
		print('No')


known = list(input())
n = int(input())
flag = 1
for i in range(n):
	s = input()
	for i in s:
		if i in known:
			pass
		else:
			print('No')
			flag = 0
			break
	if flag:
		print('Yes')
	else:
		flag = 1


def fun(w, s):
	for i in w:
		if i in s:
			continue
		else:
			return 'No'
	return 'Yes'
s = input()
for i in range(int(input())):
	w = input()
	print(fun(w, s))


n = input()
x = int(input())
for i in range(x):
	k = input()
	p = 0
	for i in range(len(k)):
		if k[i] not in n:
			print('No')
			p = 1
			break
	if p == 0:
		print('Yes')


s = list(input())
t = int(input())
for i in range(t):
	st = list(input())
	c = 0
	for i in range(len(st)):
		if st[i] in s:
			c = c + 1
		else:
			break
	if c == len(st):
		print('Yes')
	else:
		print('No')


s = input()
words_in_book = int(input())
count = 0
while words_in_book > 0:
	word = input()
	for i in s:
		for j in word:
			if i == j:
				count = count + 1
	if count == len(word):
		print('Yes')
	else:
		print('No')
	count = 0
	words_in_book = words_in_book - 1


s = input()
t = int(input())
for i in range(t):
	b = input()
	c = 0
	for l in b:
		if l not in s:
			c = 1
			break
	if c == 1:
		print('No')
	else:
		print('Yes')


st = input()
for i in range(int(input())):
	word = input()
	for letter in word:
		if letter not in st:
			print('No')
			break
	else:
		print('Yes')


a = list(input())
n = int(input())
for i in range(n):
	flag = 0
	c = list(input())
	for j in c:
		if j in a:
			continue
		else:
			flag = 1
			print('No')
			break
	if flag == 0:
		print('Yes')


s = input()
for i in range(int(input())):
	w = input()
	for j in w:
		if j not in s:
			print('No')
			break
	else:
		print('Yes')


def main(alphabet, word):
	cntChars = 0
	for char in word:
		if char not in alphabet:
			cntChars = cntChars + 1
	if cntChars == 0:
		print('Yes')
	else:
		print('No')
alphabet = input()
N = int(input())
for i in range(N):
	word = input()
	main(alphabet, word)


s = input()
for _ in range(int(input())):
	count = 0
	w = input()
	for j in range(len(s)):
		for k in range(len(w)):
			if s[j] == w[k]:
				count += 1
	if count == len(w):
		print('Yes')
	else:
		print('No')


a = input()
f = len(a)
t = int(input())
for i in range(t):
	count = 0
	s = input()
	n = len(s)
	for j in range(f):
		for k in range(n):
			if a[j] == s[k]:
				count += 1
	if count == n:
		print('Yes')
	else:
		print('No')