#include using namespace std; using ll = long long; struct Trie{ struct Node { std::array child; int sz; Node(void) :sz(0) { child.fill(-1); } const int& operator[](int k) const { return child[k]; } int& operator[](int k) { return child[k]; } }; int num; vector tree; Trie() : num(0) { tree.push_back(Node()); } void insert(const string &s){ int cur=0; for(auto c:s){ if(tree[cur][c-'a']==-1){ tree[cur][c-'a']=++num; tree.push_back(Node()); } cur=tree[cur][c-'a']; } tree[cur].sz++; } int size(const string &s){ int cur=0; for(auto c:s){ if(tree[cur][c-'a']==-1)return 0; cur=tree[cur][c-'a']; } return tree[cur].sz; } int size(int node_num){ return (node_num==-1?0:tree[node_num].sz); } int search(string &s){ function dfs = [&](int v, int f, int d){ if(d == s.size()){ return (tree[v].sz >= 1 ? true : false); } int c0 = s[d] - 'a'; for(int i = 0; i < 26; i++){ if(tree[v][i] == -1)continue; if(c0 != i){ if(f == 1)continue; if(d + 1 >= s.size())continue; int c1 = s[d + 1] - 'a'; if(tree[v][c1] == -1)continue; int nxt = tree[tree[v][c1]][c0]; if(nxt == -1)continue; if(dfs(nxt, 1, d + 2))return true; }else{ if(dfs(tree[v][i], f, d + 1))return true; } } return false; }; return dfs(0, 0, 0); } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); Trie trie; int q; cin >> q; string s; while(q--){ cin >> s; cout << (trie.search(s) ? "Yes" : "No") << '\n'; trie.insert(s); } }