using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static int state = 0; static bool hackerrankAutomaton(string str) { state = 0; for(int i = 0; i < str.Length; i++) { char ch = str[i]; switch(state) { case 0: if(ch == 'h') state = 1; break; case 1: if(ch == 'a') state = 2; break; case 2: if(ch == 'c') state = 3; break; case 3: if(ch == 'k') state = 4; break; case 4: if(ch == 'e') state = 5; break; case 5: if(ch == 'r') state = 6; break; case 6: if(ch == 'r') state = 7; break; case 7: if(ch == 'a') state = 8; break; case 8: if(ch == 'n') state = 9; break; case 9: if(ch == 'k') state = 10; break; } } if(state == 10) return true; return false; } static void Main(String[] args) { int q = Convert.ToInt32(Console.ReadLine()); for(int a0 = 0; a0 < q; a0++){ string s = Console.ReadLine(); if(hackerrankAutomaton(s)) Console.WriteLine("YES"); else Console.WriteLine("NO"); } } }