#include using namespace std; #define rep(i,n) for(int i = 0; i < (int)(n); ++i) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; --i) #define ALL(a) a.begin(), a.end() #define Sort(a) sort(a.begin(), a.end()) #define RSort(a) sort(a.rbegin(), a.rend()) typedef long long int ll; typedef long double ld; typedef vector vi; typedef vector vll; typedef vector vc; typedef vector vst; typedef vector vd; typedef pair P; const long long INF = 0x1fffffffffffffff; const long long MOD = 998244353; const long double PI = acos(-1); template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template inline T vin(T& vec, U n) { vec.resize(n); for(int i = 0; i < (int) n; ++i) cin >> vec[i]; return vec; } template inline void vout(T vec, string s = "\n"){ for(auto x : vec) cout << x << s; } template void in(T&... a){ (cin >> ... >> a); } void out(){ cout << '\n'; } template void out(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } template void inGraph(vector>& G, U n, U m, bool directed = false){ G.resize(n); for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; a--, b--; G[a].push_back(b); if(!directed) G[b].push_back(a); } } struct RollingHash{ vector hashed, power; static constexpr unsigned long mod = (1uL << 61) - 1; unsigned long mul(__int128_t a, __int128_t b) const { __int128_t t = a * b; t = (t >> 61) + (t & mod); if(t >= mod) return t - mod; return t; } RollingHash(const string &s, unsigned base = 10007){ int siz = (int) s.size(); hashed.assign(siz + 1, 0); power.assign(siz + 1, 0); power[0] = 1; for(int i = 0; i < siz; i++){ power[i + 1] = mul(power[i], base); hashed[i + 1] = mul(hashed[i], base) + s[i]; if(hashed[i + 1] >= mod) hashed[i + 1] -= mod; } } unsigned long get(int l, int r) const { unsigned long ret = hashed[r] + mod - mul(hashed[l], power[r - l]); if(ret >= mod) ret -= mod; return ret; } unsigned long connect(unsigned long h1, unsigned long h2, int h2len) const { unsigned long ret = mul(h1, power[h2len]) + h2; if(ret >= mod) ret -= mod; return ret; } int LCP(const RollingHash &b, int l1, int r1, int l2, int r2){ int len = min(r1 - l1, r2 - l2); int low = -1, high = len + 1; while(high - low > 1){ int mid = (low + high) / 2; if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid; else high = mid; } return low; } }; ll n; vst s; void input(){ in(n); vin(s, n); } void solve(){ vector> mp(1000001); rep(i, n){ string ans = "No"; RollingHash rh(s[i]); ll m = s[i].size(); rep(j, m - 1){ ll hashed = rh.get(0, j); ll a = rh.get(j, j + 1), b = rh.get(j + 1, j + 2); hashed = rh.connect(hashed, b, 1); hashed = rh.connect(hashed, a, 1); if(j != m - 2){ ll c = rh.get(j + 2, m); hashed = rh.connect(hashed, c, m - j - 2); } if(mp[m].count(hashed) != 0){ ans = "Yes"; break; } } if(mp[m].count(rh.get(0, m)) != 0){ ans = "Yes"; } mp[m][rh.get(0, m)] = 1; out(ans); } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); input(); solve(); }