import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] letters = {'h','a','c','k','e','r','r','a','n','k'}; int lettersSize = letters.length; final int sumCharValue = 1050; int q = in.nextInt(); for(int a0 = 0; a0 < q; a0++){ String s = in.next(); // your code goes here char[] compare = s.toCharArray(); int compareSize = compare.length; int count = 0; int countChar = 0; boolean contain = false; if(compareSize >= lettersSize) //String to be compare with have at least the same quantity of letters { for(int a = 0; a < compareSize; a++) { if((lettersSize - count) > (compareSize - a)) { //Verify if the quantity of letters remaining are enough to perform all tests until end break; } if(Character.compare(compare[a], letters[count]) == 0) { count++; countChar += compare[a]; if(countChar == sumCharValue) { contain = true; break; } } } } if(contain) System.out.println("YES"); else System.out.println("NO"); } } }