#include using namespace std; template class y_combinator { F f; public: y_combinator(F&& f) : f(std::forward(f)) {} template auto operator()(Args&&... args) const { return f(*this, std::forward(args)...); } }; using ll = long long; using u32 = unsigned int; using u64 = unsigned long long; using vi = vector; using vl = vector; using pii = pair; using pll = pair; template using vc = vector; template using vvc = vector>; template > using prique = priority_queue, U>; #define overload(a, b, c, d, e, ...) e #define pb push_back #define len(x) (ll)(x.size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep1(n) for (ll _ = 0; _ < ll(n); _++) #define rep2(i, n) for (ll i = 0; i < ll(n); i++) #define rep3(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define rep4(i, a, b, c) for (ll i = ll(a); i < ll(b); i += ll(c)) #define rep(...) overload(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep(i, n) for (ll i = ll(n) - 1; i >= 0; i--) template vector cumsum(const vector& a) { vector res(a.size() + 1); rep(i, a.size()) res[i + 1] = res[i] + a[i]; return res; } template void dedup(vector& a) { sort(all(a)), a.erase(unique(all(a)), a.end()); } template bool chmax(T& a, const S& b) { return a < static_cast(b) ? a = static_cast(b), 1 : 0; } template bool chmin(T& a, const S& b) { return a > static_cast(b) ? a = static_cast(b), 1 : 0; } namespace cppio { template struct is_tuple_like : false_type {}; template struct is_tuple_like> : true_type {}; template struct is_tuple_like> : true_type {}; template struct is_container : false_type {}; template struct is_container()))>> : bool_constant, string> && !is_same_v, char*> && !is_same_v, const char*> && !is_array_v>> {}; template void _in(T& x) { if constexpr (is_tuple_like::value) apply([](auto&... elems) { (_in(elems), ...); }, x); else if constexpr (is_container::value) { for (auto& e : x) _in(e); } else cin >> x; } template void _in_all(Ts&... args) { (_in(args), ...); } template void _out(const T& x) { bool first = true; if constexpr (is_tuple_like::value) { apply([&](const auto&... elems) { ((cout << (first ? "" : " "), _out(elems), first = false), ...); }, x); } else if constexpr (is_container::value) { for (const auto& e : x) { if (!first) cout << ' '; _out(e), first = false; } } else cout << x; } template void _print(const Ts&... args) { bool first = true; ((cout << (first ? "" : " "), _out(args), first = false), ...); } template void _out_no_el(const Ts&... args) { _print(args...); } template void _out_all(const Ts&... args) { _out_no_el(args...), cout << '\n'; } } // namespace cppio #define IN(...) cppio::_in_all(__VA_ARGS__) #define OUT(...) cppio::_out_all(__VA_ARGS__) #define INT(...) int __VA_ARGS__; IN(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; IN(__VA_ARGS__) #define STR(...) string __VA_ARGS__; IN(__VA_ARGS__) #define CHR(...) char __VA_ARGS__; IN(__VA_ARGS__) #define DBL(...) double __VA_ARGS__; IN(__VA_ARGS__) #define VEC(type, name, size) vector name(size); IN(name) #define VV(type, name, h, w) vector> name(h, vector(w)); IN(name) #define RETURN(...) do { __VA_ARGS__; return; } while (0) inline bool Yes(bool b = true) { return OUT(b ? "Yes" : "No"), b; } inline bool No(bool b = true) { return Yes(!b), b; } inline bool YES(bool b = true) { return OUT(b ? "YES" : "NO"), b; } inline bool NO(bool b = true) { return YES(!b), b; } #ifdef ONLINE_JUDGE #define debug(...) (void(0)) #endif class Modint61 { u64 value; using mint = Modint61; static constexpr u64 MOD = (static_cast(1) << 61) - 1; static constexpr u64 MASK61 = (static_cast(1) << 61) - 1; static constexpr u64 MASK31 = (static_cast(1) << 31) - 1; static constexpr u64 MASK30 = (static_cast(1) << 30) - 1; static constexpr u64 calc_mul(u64 a, u64 b) { u64 c = a >> 31, d = b >> 31; a &= MASK31, b &= MASK31; u64 mid = c * b + a * d; return calc_mod(((c * d) << 1) + (a * b) + (mid >> 30) + ((mid & MASK30) << 31)); } static constexpr u64 calc_mod(u64 x) { u64 a = x >> 61, b = x & MASK61; return (a + b >= MOD ? a + b - MOD : a + b); } public: static constexpr u64 mod() { return MOD; } static mint raw(u64 x) { mint t; t.value = x; return t; } Modint61() : value(0) {} Modint61(ll x) { x %= MOD; if (x < 0) x += MOD; value = x; } u64 val() const { return value; } mint& operator++() { value++; if (value == MOD) value = 0; return *this; } mint& operator--() { if (value == 0) value = MOD; value--; return *this; } mint operator++(int) { mint result = *this; ++*this; return result; } mint operator--(int) { mint result = *this; --*this; return result; } mint& operator+=(const mint& rhs) { value += rhs.value; if (value >= MOD) value -= MOD; return *this; } mint& operator-=(const mint& rhs) { if (value < rhs.value) value += MOD; value -= rhs.value; return *this; } mint& operator*=(const mint& rhs) { value = calc_mul(value, rhs.value); return *this; } mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); } mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } mint pow(long long n) const { mint res = raw(1), x = *this; while (n > 0) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } mint inv() const { return pow(MOD - 2); } friend mint operator+(const mint& lhs, const mint& rhs) { return mint(lhs) += rhs; } friend mint operator-(const mint& lhs, const mint& rhs) { return mint(lhs) -= rhs; } friend mint operator*(const mint& lhs, const mint& rhs) { return mint(lhs) *= rhs; } friend mint operator/(const mint& lhs, const mint& rhs) { return mint(lhs) /= rhs; } friend bool operator==(const mint& lhs, const mint& rhs) { return lhs.value == rhs.value; } friend bool operator!=(const mint& lhs, const mint& rhs) { return lhs.value != rhs.value; } }; using mint = Modint61; const u64 R = 27328473847893uLL; void run_case() { INT(N); vector pw(1 << 20, 1); rep(i, 1, 1 << 20) pw[i] = pw[i - 1] * R; set st; rep(it, N) { STR(S); const int L = S.size(); vector pref(L + 1); rep(i, L) pref[i + 1] = pref[i] * R + S[i]; bool ok = false; if (st.find(pref[L].val()) != st.end()) ok = true; rep(i, L - 1) { auto x = pref[i]; x *= R, x += S[i + 1]; x *= R, x += S[i]; mint r = pref[L] - pref[i + 2] * pw[L - i - 2]; x *= pw[L - i - 2], x += r; if (st.find(x.val()) != st.end()) { ok = true; break; } } Yes(ok); st.insert(pref[L].val()); } } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::fixed(std::cout).precision(16); int t = 1; while (t--) run_case(); }