Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with n strings. Then the mechanism should be able to process queries of the following type: "Given string s, determine if the memory of the mechanism contains string t that consists of the same number of characters as s and differs from s in exactly one position".

Watto has already compiled the mechanism, all that's left is to write a program for it and check it on the data consisting of n initial lines and m queries. He decided to entrust this job to you.


-----Input-----

The first line contains two non-negative numbers n and m (0 ≤ n ≤ 3·10^5, 0 ≤ m ≤ 3·10^5) — the number of the initial strings and the number of queries, respectively.

Next follow n non-empty strings that are uploaded to the memory of the mechanism.

Next follow m non-empty strings that are the queries to the mechanism.

The total length of lines in the input doesn't exceed 6·10^5. Each line consists only of letters 'a', 'b', 'c'.


-----Output-----

For each query print on a single line "YES" (without the quotes), if the memory of the mechanism contains the required string, otherwise print "NO" (without the quotes).


-----Examples-----
Input
2 3
aaaaa
acacaca
aabaa
ccacacc
caaac

Output
YES
NO
NO

Difficulty: interview

Starter code:

Solutions:
import sys


u = []
t = set()

p1 = 127
m1 = 1000000007

p2 = 131
m2 = 1000000009

pow1 = [1] + [0] * 600005
pow2 = [1] + [0] * 600005

for i in range(1, 600005):
    pow1[i] = (pow1[i-1] * p1) % m1
    pow2[i] = (pow2[i-1] * p2) % m2

def hash1(n):
    hsh = 0
    for i in range(len(n)):
        hsh += pow1[i] * ord(n[i])
        hsh %= m1
    return hsh % m1

def hash2(n):
    hsh = 0
    for i in range(len(n)):
        hsh += pow2[i] * ord(n[i])
        hsh %= m2
    return hsh % m2

a,b = list(map(int,sys.stdin.readline().split()))

def trans(n):
    a = hash1(n)
    b = hash2(n)
    cyc = ['a', 'b', 'c']
    for i in range(len(n)):
        for x in range(3):
            if cyc[x] == n[i]:
                h11 = a - ord(n[i]) * pow1[i] + ord(cyc[(x+1)%3]) * pow1[i]
                h12 = b - ord(n[i]) * pow2[i] + ord(cyc[(x+1)%3]) * pow2[i]
                h21 = a - ord(n[i]) * pow1[i] + ord(cyc[(x+2)%3]) * pow1[i]
                h22 = b - ord(n[i]) * pow2[i] + ord(cyc[(x+2)%3]) * pow2[i]
                t.add((h11%m1)*m2 + h12%m2)
                t.add((h21%m1)*m2 + h22%m2)

for i in range(a):
    trans(sys.stdin.readline())

for j in range(b):
    inpt = sys.stdin.readline()
    if hash1(inpt)*m2 + hash2(inpt) in t:
        print("YES")
    else:
        print("NO")


from sys import stdin
from functools import reduce
from collections import defaultdict
data = stdin.read().split('\n')
n, m = [int(x) for x in data[0].split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

def insert(s):
    hs[len(s)].add(h(s))

def find(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

for i in range(n):
    s = data[i + 1]
    insert(s)
buf = []
for i in range(m):
    s = data[i + n + 1]
    buf.append('YES' if find(s) else 'NO')
print('\n'.join(buf))


from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

def insert(s):
    hs[len(s)].add(h(s))

def find(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

for i in range(n):
    s = input()
    insert(s)
buf = []
for i in range(m):
    s = input()
    buf.append('YES' if find(s) else 'NO')
print('\n'.join(buf))


from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

def insert(s):
    hs[len(s)].add(h(s))

def find(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

for i in range(n):
    s = input()
    insert(s)
buf = []
for i in range(m):
    s = input()
    buf.append('YES' if find(s) else 'NO')
print('\n'.join(buf))


from collections import defaultdict
from math import ceil,floor
import sys

memory = set()
mod = 1000000000000000003
p = 3

def hash_(s):
    pp = p
    result = 0
    for ch in s:
        result += pp*(ord(ch)-ord('a')-1)
        pp = (pp*p)%mod;
        result %= mod
    return result % mod;

def find(q):
    hash_0 = hash_(q)
    k = len(q)
    pw = p
    ext = 0
    for j in range(len(q)):
        for ch in 'abc':
            if ch != q[j]:
                if ((hash_0 % mod + ((ord(ch)-ord(q[j]))*pw)% mod ) % mod) in memory:
                    sys.stdout.write('YES\n')
                    ext = 1
                    break
        if ext:
            break
        pw = (p * pw) % mod;
    if not ext:
        sys.stdout.write('NO\n')

def main():
    n,m = [int(i) for i in input().split()]
    for i in range(n):
        memory.add(hash_(sys.stdin.readline().strip()))
    for i in range(m):
        find(sys.stdin.readline().strip())
   
            
def __starting_point():
    ##sys.stdin = open("in.txt",'r') 
    ##sys.stdout = open("out.txt",'w')
    main()
    ##sys.stdin.close()
    ##sys.stdout.close()

__starting_point()

from collections import defaultdict
from math import ceil,floor
import sys

memory = set()
mod = 1000000000000000003
p = 3

def hash_(s):
    pp = p
    result = 0
    for ch in s:
        result += pp*(ord(ch)-ord('a')-1)
        pp = (pp*p)%mod;
        result %= mod
    return result % mod;

def find(q):
    hash_0 = hash_(q)
    k = len(q)
    pw = p
    ext = 0
    for j in range(len(q)):
        for ch in 'abc':
            if ch != q[j]:
                if ((hash_0 % mod + ((ord(ch)-ord(q[j]))*pw)% mod ) % mod) in memory:
                    sys.stdout.write('YES\n')
                    ext = 1
                    break
        if ext:
            break
        pw = (p * pw) % mod;
    if not ext:
        sys.stdout.write('NO\n')

def main():
    n,m = [int(i) for i in input().split()]
    for i in range(n):
        memory.add(hash_(sys.stdin.readline().strip()))
    for i in range(m):
        find(sys.stdin.readline().strip())
   
            
def __starting_point():
    ##sys.stdin = open("in.txt",'r') 
    ##sys.stdout = open("out.txt",'w')
    main()
    ##sys.stdin.close()
    ##sys.stdout.close()

__starting_point()

from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

def insert(s):
    hs[len(s)].add(h(s))

def find(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

for i in range(n):
    s = input()
    insert(s)
buf = []
for i in range(m):
    s = input()
    buf.append('YES' if find(s) else 'NO')
print('\n'.join(buf))

n, m = list(map(int, input().split()))
mod = 9999999999999983
v = set()
for i in range(n):
	s = input()
	l = len(s)
	pow = 1
	h = 0
	for i in range(l):
		h = (h + ord(s[i]) * pow) % mod
		pow = (pow * 203) % mod
	pow = 1
	for i in range(l):
		for j in range(97, 100):
			if ord(s[i]) != j:
				v.add((h + (j - ord(s[i])) * pow) % mod)
		pow = (pow * 203) % mod
ans = []
for i in range(m):
	s = input()
	pow = 1
	h = 0
	for i in range(len(s)):
		h = (h + ord(s[i]) * pow) % mod
		pow = (pow * 203) % mod
	ans.append('YES' if h in v else 'NO')
print('\n'.join(ans))


n,m=list(map(int,input().split()))
M=9999999999999983
v=set()
for i in range(n):
	s=input()
	l=len(s)
	pow=1
	h=0
	for i in range(l):
		h,pow=(h+ord(s[i])*pow)%M,(pow*203)%M
	pow=1
	for i in range(l):
		for j in range(97,100):
			if ord(s[i])!=j:
				v.add((h+(j-ord(s[i]))*pow)%M)
		pow=(pow*203)%M
ans=[]
for i in range(m):
	s=input()
	pow=1
	h=0
	for i in range(len(s)):
		h,pow=(h+ord(s[i])*pow)%M,(pow*203)%M
	ans.append('YES' if h in v else 'NO')
print('\n'.join(ans))


from sys import stdin
from collections import defaultdict
from time import time

P=829
MOD=2233333333333

def hashing(s,P,MOD) :
    h=0
    b=1
    for i in s :
        h+=b*ord(i)
        h%=MOD
        b*=P
        b%=MOD
    return h

def determine(w,lw) :
    return hashing(w,P,MOD) in mem[lw]

chars=['a','b','c']

n,m=list(map(int,input().split()))
S=time()
mem=defaultdict(set)
for i in range(n) :
    t=input()
    h0=hashing(t,P,MOD)
    lt=len(t)
    b=1
    for j in range(lt) :
        for c in chars :
            if not t[j]==c :
                #h=(h0+b*(ord(c)-ord(t[j])))%MOD
                mem[lt].add((h0+b*(ord(c)-ord(t[j])))%MOD)
        b*=P
        b%=MOD

prt=[]
for i in range(m) :
    w=input()
    lw=len(w)
    if lw not in mem :
        prt.append('NO')
        continue
    if determine(w,lw) :
        prt.append('YES')
    else :
        prt.append('NO')

print('\n'.join(prt))

#print((time()-S)*1000)


from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

def insert(s):
    hs[len(s)].add(h(s))

def find(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

for i in range(n):
    s = input()
    insert(s)
buf = []
for i in range(m):
    s = input()
    buf.append('YES' if find(s) else 'NO')
print('\n'.join(buf))


__author__ = 'Utena'
M=100000000000007
def hash(x):
    a=0
    for j1 in x:
        a=(a*1003+ord(j1))%M
    return a
def get(q):
    l=len(q)
    e=1
    h=hash(q)
    for j in range(1,l+1):
        aj=q[-j]
        a,b,c=((h+(e*(ord('a')-ord(aj))))+M*2)%M,((h+(e*(ord('b')-ord(aj))))+M*2)%M,((h+(e*(ord('c')-ord(aj))))+M*2)%M
        e=(e*1003)%M
        if aj=='a':
            if b in search[l] or c in search[l]:
                return 'YES'
        elif aj=='b':
            if a in search[l] or c in search[l]:
                return 'YES'
        elif aj=='c':
            if a in search[l] or b in search[l]:
                return 'YES'
    return 'NO'
ans=[]
n,m=map(int,input().split())
search=[set()for i in range(600001)]
for i in range(n):
    s=input()
    search[len(s)].add(hash(s))
for i in range(m):
    q=input()
    ans.append(get(q))
print('\n'.join(ans))

n, m = map(int, input().split())
mod = 9999999999999983
v = set()
for i in range(n):
	s = input()
	l = len(s)
	pow = 1
	h = 0
	for i in range(l):
		h = (h + ord(s[i]) * pow) % mod
		pow = (pow * 203) % mod
	pow = 1
	for i in range(l):
		for j in range(97, 100):
			if ord(s[i]) != j:
				v.add((h + (j - ord(s[i])) * pow) % mod)
		pow = (pow * 203) % mod
ans = []
for i in range(m):
	s = input()
	pow = 1
	h = 0
	for i in range(len(s)):
		h = (h + ord(s[i]) * pow) % mod
		pow = (pow * 203) % mod
	ans.append('YES' if h in v else 'NO')
print('\n'.join(ans))

M = 9999999999879998

def str_hash(s):
    h = 0
    p = 1
    for c in s:
        h = (h + p * ord(c)) % M
        p = (p * 197) % M
    return h

n,m = [int(i) for i in input().split()]
a = set()
for i in range(n):
    s = input()
    h = str_hash(s)
    p = 1
    for j in range(len(s)):
       for k in range(97,100):
           if ord(s[j]) != k:
               a.add((h + p * (k - ord(s[j]))) % M)
       p = (p * 197) % M
ans = []
for i in range(m):
    s = input()
    b = str_hash(s)
    if b in a:
        ans.append('YES')
    else:
        ans.append('NO')
print ('\n'.join(ans))

[n,m]=[int(i) for i in input().split()]
v=set()
M=9999999999999983
for i in range(n):
    s=input()
    l=len(s)
    [haf,hb]=[0,1]
    for j in range(l):
        haf=(haf+hb*ord(s[j]))%M
        hb=(hb*131)%M
    hb=1
    for k in range(l):
        for j in range(97,100):
            if ord(s[k])!=j:
                v.add((haf+hb*(j-ord(s[k])))%M)
        hb=(hb*131)%M
ans=[]
for i in range(m):
    s=input()
    hb=1
    haf=0
    for j in range(len(s)):
        haf=(haf+hb*ord(s[j]))%M
        hb=(hb*131)%M
    ans.append('YES' if haf in v else 'NO')
print('\n'.join(ans))

M = 9999999999879998

def myhash(target):
	h = 0
	p = 1
	for j in target:
		h = (h + p * ord(j)) % M
		p = (p * 197) % M
	return h

def binarysearch(base, tar):
	low = 0
	high = len(base) - 1
	while low <= high:
		mid = (low + high) // 2
		midval = base[mid]
		if midval > tar:
			high = mid - 1
		elif midval < tar:
			low = mid + 1
		else: 
			return 1
	return 0

n, m = [int(i) for i in input().split()]
hashval = list()
ans = list()
for i in range(n):
	ini = input()
	h = myhash(ini)
	p = 1
	for j in range(len(ini)):
		for k in range(97,100):
			if ini[j] != chr(k):
				hashval.append((h + p * (k - ord(ini[j]))) % M)
		p = (p * 197) % M
hashval.sort()

for i in range(m):
	query = input()
	hashtem = myhash(query)
	if binarysearch(hashval, hashtem):
		ans.append('YES')
	else:
		ans.append('NO')

print('\n'.join(ans))

M=9999999999879998
def Hash(s):
    h=0
    p=1
    for c in s:
        h=(h+p*ord(c))%M
        p=(p*197)%M
    return h
n,m=list(map(int,input().split()))
a = set()
for i in range(n):
    s=input()
    h=Hash(s)
    p=1
    for j in range(len(s)):
       for k in range(97,100):
           if ord(s[j])!=k:
               a.add((h+p*(k-ord(s[j])))%M)
       p=(p*197)%M
ans=[]
for i in range(m):
    s=input()
    b=Hash(s)
    if b in a:
        ans.append('YES')
    else:
        ans.append('NO')
print('\n'.join(ans))


M=9999999999999983
def Hash(s):
    h=0
    p=1
    for c in s:
        h=(h+p*(ord(c)-94))%M
        p=(p*197)%M
    return h
n,m=list(map(int,input().split()))
a=set()
for i in range(n):
    s=input()
    h=Hash(s)
    p=1
    for j in range(len(s)):
       for k in range(97,100):
           if ord(s[j])!=k:
               a.add((h+p*(k-ord(s[j])))%M)
       p=(p*197)%M
ans=[]
for i in range(m):
    s=input()
    b=Hash(s)
    if b in a:
        ans.append('YES')
    else:
        ans.append('NO')
print('\n'.join(ans))


M=99999999999983
def Hash(s):
    h=0
    p=1
    for c in s:
        h=(h+p*(ord(c)-94))%M
        p=(p*17)%M
    return h
n,m=list(map(int,input().split()))
a=set()
for i in range(n):
    s=input()
    h=Hash(s)
    p=1
    for j in range(len(s)):
       for k in range(97,100):
           if ord(s[j])!=k:
               a.add((h+p*(k-ord(s[j])))%M)
       p=(p*17)%M
ans=[]
for i in range(m):
    s=input()
    b=Hash(s)
    if b in a:
        ans.append('YES')
    else:
        ans.append('NO')
print('\n'.join(ans))


con = 1000000000000000009
def Hash(s):
    h=0
    p=1
    for c in s:
        h=(h+p*ord(c))%con
        p=(p*197)%con
    return h
n,m=list(map(int,input().split()))
a = set()
for i in range(n):
    s=input()
    h=Hash(s)
    p=1
    for j in range(len(s)):
       for k in range(97,100):
           if ord(s[j])!=k:
               a.add((h+p*(k-ord(s[j])))%con)
       p=(p*197)%con
ans=[]
for i in range(m):
    s=input()
    b=Hash(s)
    if b in a:
        ans.append('YES')
    else:
        ans.append('NO')
print('\n'.join(ans))


N = 9999999999999999999999999999999999999984
n,m=tuple(map(int,input().split()))
memory = set()
for _ in range(n):
    su = 0
    p = 1
    entry = input()
    for letter in entry:
        su = (su + p*ord(letter))%N
        p = (p*203)%N
    p = 1
    for letter in entry:
        for i in ['a','b','c']:
            if i != letter:
                memory.add((p*(ord(i)-ord(letter))+su)%N)
        p = (p*203)%N
answer  =[]
for _ in range(m):
    su = 0
    p = 1
    for letter in input():
        su = (su + p*ord(letter))%N
        p = (p*203)%N
    if su in memory:
        answer.append('YES')
    else:
        answer.append('NO')

print('\n'.join(answer))







from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

def insert(s):
    hs[len(s)].add(h(s))

def find(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False

for i in range(n):
    s = input()
    insert(s)
buf = []
for i in range(m):
    s = input()
    buf.append('YES' if find(s) else 'NO')
print('\n'.join(buf))

from sys import stdin
from functools import reduce
from collections import defaultdict

_data = iter(stdin.read().split('\n'))
def input():
    while True:
        return next(_data)

def insert(s):
    hs[len(s)].add(h(s))

def found(s):
    v = h(s)
    b = 1
    for c in reversed(s):
        for d in 'abc':
            if c != d:
                u = (v - b * ord(c) + b * ord(d)) % MOD
                if u in hs[len(s)]:
                    return True
        b *= B
        b %= MOD
    return False		
		
n, m = [int(x) for x in input().split()]
B = 10007
MOD = 1000000000000000003
h = lambda s: reduce(lambda s, c: (B * s + ord(c)) % MOD, s, 0)
hs = defaultdict(set)

for i in range(n):
    s = input()
    insert(s)
	
text = []

for i in range(m):
    s = input()
    text.append('YES' if found(s) else 'NO')
print('\n'.join(text))

'''

@author: ChronoCorax
'''

seed = 201
div = 9999999999999983

ABC = ['a', 'b', 'c']

def hashi(s):
    L = len(s)
    h = 0;
    pseed = 1
    for i in range(L):
        h, pseed = (h + ord(s[i]) * pseed) % div, (pseed * seed) % div
    return h
    

n, m = [int(c) for c in input().split()]

S = set()

for _ in range(n):
    s = input()
    L = len(s)
    
    hashs = hashi(s)
    
    pseed = 1
    for i in range(L):
        orig = s[i]
        for c in ABC:
            if c == orig: continue
            S.add((hashs + pseed * (ord(c) - ord(orig)) + div) % div)
        pseed = (pseed * seed) % div


res = []
for _ in range(m):
    hi = hashi(input())
    if hi in S:
        res.append('YES')
    else:
        res.append('NO')
        
print('\n'.join(res))

n,m = [int(i) for i in input().split()]
memory = set()
d = 31918781974729
ans = [None] * m

def Hash(x):
    t = 0
    mul = 1
    for char in x:
        t = (t + ord(char) * mul) % d
        mul = (mul * 2193) % d
    return t

for i in range(n):
    string = input()
    t = Hash(string)
    mul = 1
    for j in range(len(string)):
        for char in 'abc':
            if string[j] != char:
                memory.add((t + (ord(char) - ord(string[j])) * mul) % d)
        mul = (mul * 2193) % d
for i in range(m):
    string = input()
    t = Hash(string)
    if t in memory:
        ans[i] = 'YES'
    else:
        ans[i] = 'NO'
print(*ans, sep = '\n')