#include #include #include #include #include #define maxn 100010 using namespace std; int n, q, tot, cnt[maxn * 30]; map ch[maxn * 30]; char opt[40], s[40]; void ins() { int x = 0; for (int i = 1; i <= n; ++ i){ if (! ch[x][s[i] - 'a']) ch[x][s[i] - 'a'] = ++ tot; x = ch[x][s[i] - 'a']; ++ cnt[x]; } } void del() { int x = 0; for (int i = 1; i <= n; ++ i){ if (! ch[x][s[i] - 'a']) return; x = ch[x][s[i] - 'a']; } int d = cnt[x]; ch[x].clear(); x = 0; for (int i = 1; i <= n; ++ i){ x = ch[x][s[i] - 'a']; cnt[x] -= d; } } bool exist() { int x = 0; for (int i = 1; i <= n; ++ i){ if (! ch[x][s[i] - 'a']) return 0; x = ch[x][s[i] - 'a']; }return cnt[x] > 0; } int main() { scanf("%d", &q); while (q --){ scanf("%s%s", opt + 1, s + 1); n = strlen(s + 1); if (opt[1] == 'i') ins(); if (opt[1] == 'd') del(); if (opt[1] == 's') puts(exist() ? "Yes" : "No"); } return 0; }