#!/bin/python3 import sys q = int(input().strip()) hacker = ['h','a','c','k','e','r'] rank = ['r','a','n','k'] for a0 in range(q): count1 = 0 count2=0 s = input().strip() test1 = [] test2 = [] for let in s: if test1 != hacker: if let is hacker[count1] and let not in test1: test1.append(let) count1=count1+1 elif let is rank[count2] and let not in test2: test2.append(let) count2=count2+1 #print(test1,test2) if test1 == hacker and test2 == rank: print("YES") else: print("NO")