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); int q = in.nextInt(); for(int a0 = 0; a0 < q; a0++){ String s = in.next(); // your code goes here //We create a new int array of size 10 because "hackerrank" contains 10 letters //We will use this array to check whether the string queried contains the aforementioned word in correct order or not int[] a = new int[10]; int chk = 0; for(int i = 0 ; i < 10 ; i++){ a[i] = 0; } //We create this char array for comparison with the query string String s1 = "hackerrank"; char[] a1 = s1.toCharArray(); int cnt = 0; //We convert the query string to char array and check char[] a2 = s.toCharArray(); int len = a2.length; //If the length is smaller , in no way can the query String contain hackerrank if(len < 10){ System.out.println("NO"); } //If the length in >= 10 only then can the query string contain hackerrank else if(len >= 10){ int index = 0; while(len > 0){ char f = s.charAt(index); if(Character.isUpperCase(f)){ break; } else{ if(a1[cnt] == a2[index]){ a[chk] = 1; chk++;//Move to Next Index of the a[] cnt++;//Move to next index of the a1[] index++;//Move to next index of the a2[] len--; } else if(a1[cnt] != a2[index]){ index++; len--; } } if(chk == 10){ break; } } //Printing the Result for the query int temp = 0; for(int i = 0 ; i < 10 ; i++){ if(a[i] == 0){ System.out.println("NO"); break; } else{ temp++; } } if(temp == 10){ System.out.println("YES"); } } } } }