#include using namespace std; 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); } bool dfs(int v, bool f, int d, string &s){ if(d == s.size())return tree[v].sz >= 1 ? true : false; int c0 = s[d] - 'a'; if(f){ for(int i = d; i < s.size(); i++){ v = tree[v][s[i] - 'a']; if(v == -1)return false; } return tree[v].sz >= 1 ? true : false; } for(int i = 0; i < 26; i++){ if(tree[v][i] == -1)continue; if(c0 != i){ 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, true, d + 2, s))return true; }else{ if(dfs(tree[v][i], f, d + 1, s))return true; } } return false; } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); int Q; cin >> Q; Trie trie; string s; while(Q--){ cin >> s; cout << (trie.dfs(0, false, 0, s) ? "Yes" : "No") << '\n'; trie.insert(s); } }