#include #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 int main(){ int check[10]; for (int i = 0; i < 10; i++) { check[i] = FALSE; //printf("%d", check[i]); } int q; scanf("%d",&q); for(int a0 = 0; a0 < q; a0++){ char* s = (char *)malloc(512000 * sizeof(char)); scanf("%s",s); for (int i = 0; s[i] != '\0'; i++) { if (s[i] == 'h' && check[0] == FALSE) { check[0] = TRUE; //printf("'h' found at s[%d]\n", i); } else if ((s[i] == 'a') && (check[1] == FALSE) && (check[0] == TRUE)) { check[1] = TRUE; //printf("'a' found at s[%d]\n", i); } else if ((s[i] == 'c') && (check[2] == FALSE) && (check[1] == TRUE)) { check[2] = TRUE; //printf("'c' found at s[%d]\n", i); } else if ((s[i] == 'k') && (check[3] == FALSE) && (check[2] == TRUE)) { check[3] = TRUE; //printf("'k' found at s[%d]\n", i); } else if ((s[i] == 'e') && (check[4] == FALSE) && (check[3] == TRUE)) { check[4] = TRUE; //printf("'e' found at s[%d]\n", i); } else if ((s[i] == 'r') && (check[5] == FALSE) && (check[4] == TRUE)) { check[5] = TRUE; //printf("'r' found at s[%d]\n", i); } else if ((s[i] == 'r') && (check[6] == FALSE) && (check[5] == TRUE)) { check[6] = TRUE; //printf("'r' found at s[%d]\n", i); } else if ((s[i] == 'a') && (check[7] == FALSE) && (check[6] == TRUE)) { check[7] = TRUE; //printf("'a' found at s[%d]\n", i); } else if ((s[i] == 'n') && (check[8] == FALSE) && (check[7] == TRUE)) { check[8] = TRUE; //printf("'n' found at s[%d]\n", i); } else if ((s[i] == 'k') && (check[9] == FALSE) && (check[8] == TRUE)) { check[9] = TRUE; //printf("'k' found at s[%d]\n", i); break; } } if (check[9] == TRUE && a0 != q) { printf("YES\n"); } else if (check[9] == FALSE && a0 != q) { printf("NO\n"); } if (check[9] == TRUE && a0 == q) { printf("YES"); } else if (check[9] == FALSE && a0 == q) { printf("NO"); } for (int i = 0; i < 10; i++) { check[i] = FALSE; } } return 0; }