#include #include using namespace std; using namespace atcoder; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--) #define repk(i, k, n) for (int i = k; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define mod1 1000000007 #define mod2 998244353 #define mod3 100000007 #define vi vector #define vs vector #define vc vector #define vl vector #define vvi vector> #define vvc vector> #define vvl vector> #define vvvi vector>> #define vvvl vector>> #define pii pair #define pil pair #define pli pair #define pll pair #define vpii vector> #define vpll vector> #define vvpii vector>> #define vvpll vector>> template void debug(T e){ cerr << e << endl; } template void debug(vector &v){ rep(i, v.size()){ cerr << v[i] << " "; } cerr << endl; } template void debug(vector> &v){ rep(i, v.size()){ rep(j, v[i].size()){ cerr << v[i][j] << " "; } cerr << endl; } } template void debug(vector> &v){ rep(i,v.size()){ cerr << v[i].first << " " << v[i].second << endl; } } template void debug(set &st){ for (auto itr = st.begin(); itr != st.end(); itr++){ cerr << *itr << " "; } cerr << endl; } template void debug(multiset &ms){ for (auto itr = ms.begin(); itr != ms.end(); itr++){ cerr << *itr << " "; } cerr << endl; } template void debug(map &mp){ for (auto itr = mp.begin(); itr != mp.end(); itr++){ cerr << itr->first << " " << itr->second << endl; } } void debug_out(){ cerr << endl; } template void debug_out(Head H, Tail... T){ cerr << H << " "; debug_out(T...); } ll mk_hash(string S, ll h, ll mod){ ll num = 1; ll ret = 0; for (ll i = 0; i < S.size(); i++){ ret = (ret * h) % mod; ret = (ret + (S[i] - 'a')) % mod; } return ret; } ll to_single_val(ll hashs, ll len){ return hashs * 1000000 + len; } int main(){ int N; cin >> N; vs S(N); unordered_map mp1; unordered_map mp2; unordered_map mp3; rep(i,N) cin >> S[i]; ll h1 = 1009; ll h2 = 997; ll h3 = 991; vl pows1(1000002); vl pows2(1000002); vl pows3(1000002); pows1[0] = 1; pows2[0] = 1; pows3[0] = 1; for (ll i = 0; i < 1000001; i++){ pows1[i + 1] = (pows1[i] * h1) % mod1; pows2[i + 1] = (pows2[i] * h2) % mod2; pows3[i + 1] = (pows3[i] * h3) % mod3; } for (ll i = 0; i < N; i++){ bool pos = false; ll hash1 = mk_hash(S[i], h1, mod1); ll hash2 = mk_hash(S[i], h2, mod2); ll hash3 = mk_hash(S[i], h3, mod3); if (mp1[to_single_val(hash1, S[i].size())] && mp2[to_single_val(hash2, S[i].size())] && mp3[to_single_val(hash3, S[i].size())]){ pos = true; } ll len = S[i].size(); for (ll j = 0; j < len - 1; j++){ ll new_hash1 = hash1; new_hash1 = (new_hash1 - ((ll)(S[i][j] - 'a') * pows1[len - 1 - j]) % mod1 + mod1) % mod1; new_hash1 = (new_hash1 + ((ll)(S[i][j + 1] - 'a') * pows1[len - 1 - j]) % mod1 + mod1) % mod1; new_hash1 = (new_hash1 - ((ll)(S[i][j + 1] - 'a') * pows1[len - 1 - (j + 1)]) % mod1 + mod1) % mod1; new_hash1 = (new_hash1 + ((ll)(S[i][j] - 'a') * pows1[len - 1 - (j + 1)]) % mod1 + mod1) % mod1; ll new_hash2 = hash2; new_hash2 = (new_hash2 - ((ll)(S[i][j] - 'a') * pows2[len - 1 - j]) % mod2 + mod2) % mod2; new_hash2 = (new_hash2 + ((ll)(S[i][j + 1] - 'a') * pows2[len - 1 - j]) % mod2 + mod2) % mod2; new_hash2 = (new_hash2 - ((ll)(S[i][j + 1] - 'a') * pows2[len - 1 - (j + 1)]) % mod2 + mod2) % mod2; new_hash2 = (new_hash2 + ((ll)(S[i][j] - 'a') * pows2[len - 1 - (j + 1)]) % mod2 + mod2) % mod2; ll new_hash3 = hash3; new_hash3 = (new_hash3 - ((ll)(S[i][j] - 'a') * pows3[len - 1 - j]) % mod3 + mod3) % mod3; new_hash3 = (new_hash3 + ((ll)(S[i][j + 1] - 'a') * pows3[len - 1 - j]) % mod3 + mod3) % mod3; new_hash3 = (new_hash3 - ((ll)(S[i][j + 1] - 'a') * pows3[len - 1 - (j + 1)]) % mod3 + mod3) % mod3; new_hash3 = (new_hash3 + ((ll)(S[i][j] - 'a') * pows3[len - 1 - (j + 1)]) % mod3 + mod3) % mod3; //debug(new_hash); //debug(to_single_val(new_hash, S[i].size())); if (mp1[to_single_val(new_hash1, S[i].size())] && mp2[to_single_val(new_hash2, S[i].size())] && mp3[to_single_val(new_hash3, S[i].size())]){ pos = true; } /*if (mp[pll(new_hash, S[i].size())]){ pos = true; }*/ } if (pos) cout << "Yes" << endl; else cout << "No" << endl; mp1[to_single_val(hash1, S[i].size())]++; mp2[to_single_val(hash2, S[i].size())]++; mp3[to_single_val(hash3, S[i].size())]++; } }