#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.emplace_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.emplace_back(Node()); } cur = tree[cur][c - 'a']; } tree[cur].sz++; } bool dfs(int v, int d, string &s){ if(d == s.size())return tree[v].sz >= 1 ? true : false; int c0 = s[d] - 'a'; if(tree[v][c0] != -1 && dfs(tree[v][c0], d + 1, s))return true; else{ if(d + 1 >= s.size())return false; int c1 = s[d + 1] - 'a'; if(tree[v][c1] == -1)return false; int cur = tree[tree[v][c1]][c0]; if(cur == -1)return false; for(int i = d + 2; i < s.size(); i++){ cur = tree[cur][s[i] - 'a']; if(cur == -1)return false; } return tree[cur].sz ? true : false; } 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, 0, s) ? "Yes" : "No") << '\n'; trie.insert(s); } }