using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { int q = Convert.ToInt32(Console.ReadLine()); string[] strArr = new[] {"h", "a", "c", "k", "e", "r", "r", "a", "n", "k"}; for(int a0 = 0; a0 < q; a0++){ string s = Console.ReadLine(); string VAL = "YES"; if (!string.IsNullOrEmpty(s)) { int lastIndex = -1; for (int i = 0; i < strArr.Length; i++) { int tempIndex = 0; int cnt = s.Count(j => j == Convert.ToChar(strArr[i])); bool found = false; while (cnt > 0) { if (s.IndexOf(strArr[i],tempIndex) > lastIndex) { lastIndex = s.IndexOf(strArr[i], tempIndex); found = true; break; } else { tempIndex = s.IndexOf(strArr[i], tempIndex) + 1; } cnt--; } if(!found) { VAL = "NO"; break; } } } Console.WriteLine(VAL); } } }