class Hasher(): def __init__(self, length, base, mod): self.length=length self.base=base self.mod=mod self.power=pw=[1]*length for i in range(1,length): pw[i]=(base*pw[i-1])%mod def __repr__(self): return "length: {}\nbase: {}\nmod: {}".format(self.length, self.base, self.mod) def encode(self, S): code=0; N=len(S) for i in range(N): #code+=ord(S[i])*self.power[N-1-i]%self.mod code+=S[i]*self.power[N-1-i]%self.mod return code%self.mod def decode(self, S): pass def hashing(a,b): return a*q+b from random import randint n = int(input()) s = [""]*n L = 0 for i in range(n): s[i] = [ord(a) - ord("a")+ 1 for a in input()] L = max(L, len(s[i])) p = 10**9+7 beta = randint(2, p-1) q = 10**9+9 gamma = randint(2, q-1) Bp = [1]*L Bq= [1]*L Hp = Hasher(L, beta, p) Hq = Hasher(L, gamma, q) for j in range(1, L): Bp[j] = Bp[j-1]*beta%p Bq[j] = Bq[j-1]*gamma%q for j in range(L): Bp[j] *= beta-1 Bq[j] *= gamma-1 Bp[j] %= p Bq[j] %= q E = set() ans = [0]*n for i in range(n): hp = Hp.encode(s[i]) hq = Hq.encode(s[i]) h = hashing(hp, hq) if h in E: ans[i] = 1 continue lensi = len(s[i]) for j in range(lensi-1): kp = (hp + Bp[lensi-j-2]*(s[i][j+1] - s[i][j]))%p kq = (hq + Bq[lensi-j-2]*(s[i][j+1] - s[i][j]))%q if hashing(kp, kq) in E: ans[i] = 1 E.add(h) for i in ans: print('Yes') if i else print('No')