We say that a string contains the word hackerrank if a subsequence of its characters spell the word hackerrank.  Remeber that a subsequence maintains the order of characters selected from a sequence.   

More formally, let $p[0],p[1],\cdots,p[9]$ be the respective indices of h, a, c, k, e, r, r, a, n, k in string $\boldsymbol{\mathrm{~S~}}$. If $p[0]<p[1]<p[2]<\text{...}<p[9]$ is true, then $\boldsymbol{\mathrm{~S~}}$ contains hackerrank.

For each query, print YES on a new line if the string contains hackerrank, otherwise, print NO.  

Example 

$s=\text{haacckker}\text{rannkk}$  

This contains a subsequence of all of the characters in the proper order.  Answer YES  

$s=\text{haacckkerannk}$  

This is missing the second 'r'.  Answer NO.  

$s=\text{hccaakker}\text{rannkk}$  

There is no 'c' after the first occurrence of an 'a', so answer NO.  

Function Description  

Complete the hackerrankInString function in the editor below.   

hackerrankInString has the following parameter(s):  

string s: a string   

Returns  

string: YES or NO

Input Format

The first line contains an integer $\textit{q}$, the number of queries. 

Each of the next $\textit{q}$ lines contains a single query string $\boldsymbol{\mathrm{~S~}}$.  

Constraints

$2\leq q\leq10^2$  
$10\leq\:\text{length of}\:s\leq10^4$

Sample Input 0
2
hereiamstackerrank
hackerworld

Sample Output 0
YES
NO

Explanation 0

We perform the following $q=2$ queries:

$s=\textbf{hereiamstacker}\textbf{rank}$ 

The characters of hackerrank are bolded in the string above. Because the string contains all the characters in hackerrank in the same exact order as they appear in hackerrank, we return YES.
$s=\textbf{hackerworld}$ does not contain the last three characters of hackerrank, so we return NO.

Sample Input 1
2
hhaacckkekraraannk
rhbaasdndfsdskgbfefdbrsdfhuyatrjtcrtyytktjjt

Sample Output 1
YES
NO



The diagram below depicts our map of Hackerland:

We can cover the entire city by installing $3$ transmitters on houses at locations $\begin{array}{c}4\end{array}$, $\mbox{9}$, and $12$.

Difficulty: EASY

Solutions:
import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	pattern = '.*h.*a.*c.*k.*e.*r.*r.*a.*n.*k.*'
	m = re.search(pattern, s)
	if m is not None:
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	done = False
	f = ''
	phrase = 'hackerrank'
	i = 0
	for x in range(0, len(s)):
		if s[x:x + 1] == phrase[i:i + 1]:
			f += phrase[i:i + 1]
			i += 1
		if phrase == f:
			done = True
			print('YES')
			break
	if done == False:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	gs = 'hackerrank'
	p = 0
	for l in s:
		if l == gs[p]:
			p += 1
		if p == len(gs):
			break
	if p == len(gs):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	goal_string = 'hackerrank'
	i = 0
	for char in s:
		if char == goal_string[i]:
			i += 1
		if i == 10:
			break
	if i == 10:
		print('YES')
	else:
		print('NO')


import sys
h = list('hackerrank')
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	i = -1
	j = 0
	f = False
	A = []
	for i in range(len(s)):
		if s[i] == h[0]:
			A.append(h[0])
		for j in range(len(A)):
			if len(A[j]) == len(h):
				f = True
				break
			if s[i] == h[len(A[j])]:
				A[j] += h[len(A[j])]
		if f:
			break
	for a in A:
		if len(a) == len(h):
			f = True
	if f:
		print('YES')
	else:
		print('NO')


import sys
target = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	done = False
	in_ta = 0
	for i in range(len(s)):
		if s[i] == target[in_ta]:
			in_ta += 1
			if in_ta == len(target):
				print('YES')
				done = True
				break
		if done:
			break
	if not done:
		print('NO')


import sys

def string_test(s):
	t = 'hackerrank'
	j = 0
	lst = [0 for _ in 'hackerrank']
	for i in range(len(s)):
		if j < len(t) and t[j] == s[i]:
			lst[j] = i
			j += 1
	return j == len(t) and lst == sorted(lst)
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	print('YES' if string_test(s) else 'NO')


import sys
q = int(input().strip())
for a0 in range(q):
	S = ''
	s = input().strip()
	idx = s.find('h')
	hackerrank = [idx]
	s = s[idx + 1:]
	j = 1
	pattern = 'hackerrank'
	while j < 10:
		idx = s.find(pattern[j])
		if idx == -1:
			S = 'NO'
			break
		s = s[idx + 1:]
		hackerrank.extend([idx])
		j += 1
	if S == '':
		S = 'YES'
	print(S)


str = 'hackerrank'
t = int(input())
for i in range(t):
	test = input()
	count = 0
	for j in test:
		if count < len(str):
			if j == str[count]:
				count += 1
	if count == len(str):
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if bool(re.match('(.)*h(.)*a(.)*c(.)*k(.)*e(.)*r(.)*r(.)*a(.)*n(.)*k(.)*', s)):
		print('YES')
	else:
		print('NO')


import sys
to_find = [c for c in 'hackerrank']
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	finding = 0
	for c in s:
		if to_find[finding] == c:
			finding += 1
			if finding == len(to_find):
				print('YES')
				break
	else:
		print('NO')


import sys

def hackerrank(s):
	l = list('hackerrank')
	i = 0
	for x in s:
		if x == l[i]:
			i += 1
		if i == 9:
			print('YES')
			return
	print('NO')
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	hackerrank(s)


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	goal = ['h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k']
	initial = 0
	for i in s:
		if initial >= 10:
			break
		if i == goal[initial]:
			initial += 1
	if initial >= 10:
		print('YES')
	else:
		print('NO')


import sys
x = 'hackerrank'
m = len(x)

def subsequenceID(x, s, m, n):
	if m == 0:
		return True
	if n == 0:
		return False
	if x[m - 1] == s[n - 1]:
		return subsequenceID(x, s, m - 1, n - 1)
	return subsequenceID(x, s, m, n - 1)
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	n = len(s)
	sys.setrecursionlimit(10000)
	if subsequenceID(x, s, m, n):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = list(input().strip())
	ans = 'YES'
	for h in 'hackerrank':
		if h in s:
			s = s[s.index(h):]
			s.remove(h)
		else:
			ans = 'NO'
			break
	print(ans)


import sys

def is_subsequence_of(str, word):
	cur_word_ind = 0
	for let in str:
		if let == word[cur_word_ind]:
			if cur_word_ind == len(word) - 1:
				return True
			else:
				cur_word_ind += 1
	return False
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if is_subsequence_of(s, 'hackerrank'):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
hacker = list('hackerrank')
for a0 in range(q):
	notIn = False
	s = input().strip()
	i = 0
	l = 0
	while l < len(hacker):
		try:
			i = s.index(hacker[l], i) + 1
			l += 1
		except ValueError:
			notIn = True
			break
	if notIn == True:
		print('NO')
	elif notIn == False:
		print('YES')


nTestCases = int(input().strip())
letters = 'hackerrank'
for _ in range(nTestCases):
	s = input().strip()
	startFrom = 0
	try:
		for i in range(len(letters)):
			startFrom = s.index(letters[i], startFrom) + 1
	except ValueError:
		print('NO')
	else:
		print('YES')


import sys

def has_hackerrank(string):
	x = 0
	for i in string:
		if x < len(HR) and i == HR[x]:
			x += 1
	if x == len(HR):
		print('YES')
	else:
		print('NO')
HR = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip().lower()
	has_hackerrank(s)


import sys
word = 'hackerrank'
q = int(input().strip())
d = ()
for a0 in range(q):
	s = input().strip()
	n = len(s)
	p = 0
	wi = 0
	for wi in range(len(word)):
		if wi < 9:
			p = s.find(word[wi], p) + 1
			if p == 0:
				break
	if wi == 9:
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	flag = []
	flag = [c for c in 'hackerrank']
	s = input().strip()
	for i in s:
		if len(flag) == 0:
			break
		if i == flag[0]:
			flag.remove(i)
	if len(flag) == 0:
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if re.match('^.*h+.*a+.*c+.*k+.*e+.*r+.*r+.*a+.*n+.*k+.*$', s):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = list(input().strip())
	try:
		p0 = s.index('h')
		p1 = s[p0 + 1:].index('a') + len(s[:p0 + 1])
		p2 = s[p1 + 1:].index('c') + len(s[:p1 + 1])
		p3 = s[p2 + 1:].index('k') + len(s[:p2 + 1])
		p4 = s[p3 + 1:].index('e') + len(s[:p3 + 1])
		p5 = s[p4 + 1:].index('r') + len(s[:p4 + 1])
		p6 = s[p5 + 1:].index('r') + len(s[:p5 + 1])
		p7 = s[p6 + 1:].index('a') + len(s[:p6 + 1])
		p8 = s[p7 + 1:].index('n') + len(s[:p7 + 1])
		p9 = s[p8 + 1:].index('k') + len(s[:p8 + 1])
		if p0 < p1 < p2 < p3 < p4 < p5 < p6 < p7 < p8 < p9:
			print('YES')
		else:
			print('NO')
	except:
		print('NO')


import sys
q = int(input().strip())
ref = 'hackerrank'
for a0 in range(q):
	s = input().strip()
	ct = 0
	for i in ref:
		for j in s:
			if i == j:
				s = s[s.index(j) + 1:]
				ct += 1
				break
		if ct == 10:
			print('YES')
			break
	if ct < 10:
		print('NO')


import sys
q = int(input().strip())
test = 'hackerrank'
for a0 in range(q):
	s = input().strip()
	chars = list(s)
	index = 0
	for c in chars:
		if c == test[index]:
			index += 1
		if index == len(test):
			break
	print('YES' if index == len(test) else 'NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	pal = 'hackerrank'
	start = 0
	for ch in pal:
		i = s.find(ch, start)
		if i != -1:
			start = i + 1
		else:
			print('NO')
			break
	else:
		print('YES')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	m = re.search('([hH]\\w*[aA]\\w*[cC]\\w*[kK]\\w*[rR]\\w*[rR]\\w*[aA]\\w*[nN]\\w*[kK])', s)
	if m:
		print('YES')
	else:
		print('NO')


import sys
nq = int(input().strip())
h = 'hackerrank'
for q in range(nq):
	s = input().strip()
	i = 0
	j = 0
	while i < len(h) and j < len(s):
		if h[i] == s[j]:
			i += 1
			j += 1
		else:
			j += 1
	if i == len(h):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
test = 'hackerrank'

def subseq(small, large):
	largeable = iter(large)
	if all((x in largeable for x in test)):
		print('YES')
	else:
		print('NO')
for a0 in range(q):
	s = input().strip()
	subseq(test, s)


q = int(input())
req = ['h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k']
for i in range(q):
	text = input()
	flag = 1
	k = 0
	for j in text:
		if j == req[k]:
			k += 1
		if k == 10:
			print('YES')
			break
	if k != 10:
		print('NO')


import sys
word = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	cpt_word = 0
	for c in s:
		if word[cpt_word] == str(c).lower():
			cpt_word += 1
		if cpt_word == len(word):
			break
	if cpt_word == len(word):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
w = 'hackerrank\x00'
for _ in range(q):
	s = input().strip()
	i = 0
	for c in s:
		if c == w[i]:
			i += 1
	print(('NO', 'YES')[i == 10])


import sys
q = int(input().strip())
result = []
for a0 in range(q):
	s = input().strip()
	l = list('hackerrank')
	string = list(s)
	length_l = len(l)
	length_s = len(string)
	i = 0
	new_l = []
	for j in range(length_s):
		if i < length_l:
			if l[i] == string[j]:
				new_l.append(l[i])
				i += 1
	if len(new_l) != length_l:
		result.append('NO')
	else:
		result.append('YES')
for i in range(len(result)):
	print(result[i])


import re
q = int(input().strip())
for i in range(q):
	x = input()
	pat = '.*'.join('hackerrank')
	if re.search(pat, x):
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if re.search('h.*a.*c.*k.*e.*r.*r.*a.*n.*k', s):
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if re.findall('h.*a.*c.*k.*e.*r.*r.*a.*n.*k', s):
		print('YES')
	else:
		print('NO')


import sys

def issubstr(substr, mystr, start_index=0):
	for letter in substr:
		start_index = mystr.find(letter, start_index) + 1
		if start_index == 0:
			return False
	return True
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	s = s.lower()
	if issubstr('hackerrank', s):
		print('YES')
	else:
		print('NO')


import sys
word = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	(i, j) = (0, 0)
	while i < len(s) and j < len(word):
		if word[j] == s[i]:
			i += 1
			j += 1
		else:
			i += 1
	print('YES' if j == len(word) else 'NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	checkstring = ['h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k']
	s_list = list(s)
	k = 0
	for i in range(len(s_list)):
		if k == 9:
			break
		if s_list[i] == checkstring[k]:
			k = k + 1
		elif not k == 0:
			if s_list[i] == checkstring[k - 1]:
				continue
		else:
			k = 0
	if k == 9:
		print('YES')
	else:
		print('NO')


import sys
s1 = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	count = 0
	for i in s:
		if count < 10:
			if i == s1[count]:
				count += 1
	if count == 10:
		print('YES')
	else:
		print('NO')


import sys
data = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	index = 0
	found = False
	s = input().strip()
	for i in range(len(s)):
		if s[i] == data[index]:
			index += 1
			if index >= len(data):
				print('YES')
				found = True
				break
	if not found:
		print('NO')


n = int(input())
for i in range(0, n):
	s = input()
	pos = 0
	st = 'hackerrank'
	p = 0
	while pos < len(s) and p < len(st):
		if s[pos] is st[p]:
			p = p + 1
		pos = pos + 1
	if p == len(st):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	t = len(s)
	k = 'hackerrank'
	c = [False] * len(k)
	a = True
	i = 0
	while a:
		a = False
		if k[i:i + 1] in s:
			a = True
			c[i] = True
			if False not in c:
				print('YES')
				break
			s = s[s.index(k[i:i + 1]) + 1:]
			i = i + 1
		if i >= t:
			a = False
			break
	if a != True:
		print('NO')


import sys
WORD = 'hackerrank'
LANG = len(WORD)

def check(s):
	n = 0
	for c in s:
		if c == WORD[n]:
			n += 1
			if n >= LANG:
				return True
	return False
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if check(s):
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
h = 'h.*a.*c.*k.*e.*r.*r.*a.*n.*k'
for a0 in range(q):
	s = input().strip()
	prog = re.compile(h)
	result = prog.search(s)
	if result != None:
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
word = 'hackerrank'
for a0 in range(q):
	s = input().strip()
	counter = 0
	for i in s:
		if counter >= len(word):
			break
		if i == word[counter]:
			counter += 1
	if counter >= len(word):
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if not re.findall('[^h]*h[^a]*a[^c]*c[^k]*k[^e]*e[^r]*r[^r]*r[^a]*a[^n]*n[^k]*k', s):
		print('NO')
	else:
		print('YES')


import sys
import re
matchobj = re.compile('\\w*h\\w*a\\w*c\\w*k\\w*e\\w*r\\w*r\\w*a\\w*n\\w*k\\w*')
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	result = matchobj.match(s)
	if result is None:
		print('NO')
	else:
		print('YES')


import sys

def hasHackerRankString(s):
	s_find = 'hackerrank'
	size_find = len(s_find)
	size_s = len(s)
	if size_s < size_find:
		print('NO')
	else:
		i_s = 0
		i_f = 0
		no_stop = True
		while no_stop:
			if s_find[i_f] == s[i_s]:
				i_f += 1
				i_s += 1
				if i_f == size_find:
					print('YES')
					no_stop = False
				elif i_s == size_s:
					print('NO')
					no_stop = False
			else:
				i_s += 1
				if i_s == size_s:
					print('NO')
					no_stop = False
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	hasHackerRankString(s)


testcases = int(input())
for i in range(testcases):
	word = input().lower()
	l = ['h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k']
	pos = -1
	temp = 0
	failed = False
	for letter in l:
		pos = word.find(str(letter), pos + 1)
		if pos < 0:
			failed = True
			break
	if not failed:
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	resultList = []
	for letter in 'hackerrank':
		if letter in s:
			index = s.find(letter)
			resultList.append(letter)
			s = s[index + 1:]
	result = ''.join(resultList)
	if result == 'hackerrank':
		print('YES')
	else:
		print('NO')


import sys

def ru(s):
	for i in 'hackerrank':
		ind = s.find(i)
		if ind == -1:
			print('NO')
			return
		s = s[ind + 1:]
	print('YES')
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	ru(s)


import sys
q = int(input().strip())
query = 'hackerrank'
for a0 in range(q):
	s = input().strip()
	i = 0
	for c in s:
		if c == query[i]:
			i += 1
			if i == len(query):
				break
	if i == len(query):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	d = 'hackerrank'
	i = 0
	o = 'NO'
	for x in s:
		if x == d[i]:
			i += 1
		if i == len(d):
			o = 'YES'
			break
	print(o)


import re
import sys
PATTERN = 'hackerrank'

def check(s):
	pat_idx = s_idx = 0
	while pat_idx < len(PATTERN) and s_idx < len(s):
		if s[s_idx] == PATTERN[pat_idx]:
			pat_idx += 1
		s_idx += 1
	return pat_idx == len(PATTERN)
q = int(input())
for _ in range(q):
	if check(input()):
		print('YES')
	else:
		print('NO')


def contains(s, s1):
	if not s1:
		return True
	try:
		i = s.index(s1[0])
	except ValueError:
		return False
	else:
		return contains(s[i + 1:], s1[1:])
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	s1 = 'hackerrank'
	print('YES' if contains(s, s1) else 'NO')


import sys
import fnmatch
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if fnmatch.fnmatch(s, '*h*a*c*k*e*r*r*a*n*k*'):
		print('YES')
	else:
		print('NO')


import sys
import re
rx = re.compile('.*'.join(list('hackerrank')))
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	print('YES' if rx.search(s) else 'NO')


import sys
z = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	nofound = 0
	for c in z:
		try:
			ind = s.index(c)
		except:
			ind = -1
		if ind == -1:
			nofound = 1
			print('NO')
			break
		else:
			s = s[ind + 1:]
	if nofound == 0:
		print('YES')


q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	word = 'hackerrank'
	for item in s:
		if len(word) != 0:
			if item == word[0]:
				word = word[1:]
	if len(word) == 0:
		print('YES')
	else:
		print('NO')


import sys
target = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	i = 0
	j = 0
	for i in range(len(s)):
		if s[i] == target[j]:
			j += 1
		if j == len(target):
			print('YES')
			break
	if j < len(target):
		print('NO')


import sys

def ishackerrank(s):
	pos = []
	pos.append(s.find('h'))
	i = 0
	for char in 'ackerrank':
		i += 1
		pos.append(s.find(char, pos[i - 1] + 1))
	for i in pos:
		if i == -1:
			return False
	return True
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if ishackerrank(s):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	search_index = 0
	index = 0
	hackerrank = 'hackerrank'
	contains = True
	while index < len(hackerrank):
		search_index = s.find(hackerrank[index])
		if search_index is -1:
			contains = False
			break
		s = s[search_index + 1:]
		index += 1
	if contains:
		print('YES')
	else:
		print('NO')


import sys
word = 'hackerrank'

def ch(s):
	i = 0
	for c in s:
		if c == word[i]:
			i += 1
			if i == len(word):
				return 'YES'
	return 'NO'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	print(ch(s))


import sys
o = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	i = 0
	k = 0
	while i < len(s):
		if o[k] == s[i]:
			k += 1
			if k == len(o):
				break
		i += 1
	if k == len(o) and i < len(s):
		print('YES')
	else:
		print('NO')


import sys
import re
pattern = '\\b.*h.*a.*c.*k.*e.*r.*r.*a.*n.*k.*\\b'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	match = re.match(pattern, s)
	if match is not None:
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	valid = True
	for letter in ['h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k']:
		ind = s.find(letter)
		if ind == -1:
			valid = False
			break
		s = s[ind + 1:]
	if valid:
		print('YES')
	else:
		print('NO')


import sys
tar = 'hackerrank'
tar = list(tar)
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	s = list(s)
	printed = False
	k = 0
	h = 0
	while h <= len(s) - 1:
		if tar[k] == s[h]:
			k = k + 1
			if k >= len(tar):
				print('YES')
				printed = True
				h = len(s)
		h = h + 1
	if printed == False:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	A = list(s)
	n = len(A)
	B = {'h': [], 'a': [], 'c': [], 'k': [], 'e': [], 'r': [], 'n': []}
	for i in range(n):
		if A[i] in B:
			B[A[i]].append(i)
	if B['h'] == []:
		yes = 0
		h = n
	else:
		h = min(B['h'])
	for place in range(h + 1):
		if place in B['a']:
			B['a'].remove(place)
	if B['a'] == []:
		yes = 0
		a = n - 1
	else:
		a = min(B['a'])
	for place in range(a + 1):
		if place in B['c']:
			B['c'].remove(place)
	if B['c'] == []:
		yes = 0
		c = n - 1
	else:
		c = min(B['c'])
	for place in range(c + 1):
		if place in B['k']:
			B['k'].remove(place)
	if B['k'] == []:
		yes = 0
		k = n - 1
	else:
		k = min(B['k'])
	for place in range(k + 1):
		if place in B['e']:
			B['e'].remove(place)
	if B['e'] == []:
		yes = 0
		e = n - 1
	else:
		e = min(B['e'])
	for place in range(e + 1):
		if place in B['r']:
			B['r'].remove(place)
	if B['r'] == []:
		yes = 0
		r = n - 1
	else:
		r = min(B['r'])
	for place in range(r + 1):
		if place in B['r']:
			B['r'].remove(place)
	if B['r'] == []:
		yes = 0
		r = n - 1
	else:
		r = min(B['r'])
	for place in range(r + 1):
		if place in B['a']:
			B['a'].remove(place)
	if B['a'] == []:
		yes = 0
		a = n - 1
	else:
		a = min(B['a'])
	for place in range(a + 1):
		if place in B['n']:
			B['n'].remove(place)
	if B['n'] == []:
		yes = 0
		m = n - 1
	else:
		m = min(B['n'])
	for place in range(m + 1):
		if place in B['k']:
			B['k'].remove(place)
	if B['k'] == []:
		yes = 0
		k = n - 1
	else:
		k = min(B['k'])
		yes = 1
	if yes:
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	example_str = 'hackerrank'
	index = 0
	for i in s:
		if index < 10 and i == example_str[index]:
			index += 1
	print('YES') if index == 10 else print('NO')


i = int(input())
erg = 'hackerrank'
for j in range(i):
	a = 0
	s = input()
	for c in s:
		if a >= len(erg):
			break
		if c == erg[a]:
			a += 1
	if a >= len(erg):
		print('YES')
	else:
		print('NO')


import sys
import re
regex = re.compile('h.*a.*c.*k.*e.*r.*r.*a.*n.*k.*')
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	test = re.search(regex, s)
	if test:
		print('YES')
	else:
		print('NO')


import re
q = int(input())
queries = []
for i in range(q):
	x = input()
	queries.append(x)

def find_hackerrank(raw_str):
	expression = re.compile('.*h.*a.*c.*k.*e.*r.*r.*a.*n.*k')
	ho = re.findall(expression, raw_str)
	if len(ho) > 0:
		print('YES')
	else:
		print('NO')
for i in queries:
	find_hackerrank(i)


import sys
z = int(input().strip())
for a0 in range(z):
	s = input().strip()
	q = 'hackerrank'
	si = 0
	qi = 0
	count_found = 0
	while qi < len(q) and si < len(s):
		if q[qi] == s[si]:
			qi += 1
			si += 1
			count_found += 1
		else:
			si += 1
	if count_found == len(q):
		print('YES')
	else:
		print('NO')


import sys

def issubstr(substr, mystr, start_index=0):
	try:
		for letter in substr:
			start_index = mystr.index(letter, start_index) + 1
		print('YES')
	except:
		print('NO')
myword = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	issubstr(myword, s)


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	g = 'hackerrank'
	i = 0
	for c in s:
		if c == g[i]:
			i += 1
		if i == 10:
			print('YES')
			break
	if i < 10:
		print('NO')


import sys

def check(s, to_find='hackerrank'):
	last_index = -1
	for letter in to_find:
		idx = s.find(letter, last_index + 1)
		if idx != -1:
			last_index = idx
		else:
			return False
	return True
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	print('YES' if check(s) else 'NO')


import sys
keyword = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	flag = 'NO'
	key_index = 0
	for letter in s:
		if letter == keyword[key_index]:
			key_index += 1
		if key_index == len(keyword):
			print('YES')
			break
	if key_index < len(keyword):
		print('NO')


import sys
q = int(input().strip())
word = ['h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k']
for a0 in range(q):
	poss = []
	d = 0
	s = input().strip()
	for i in range(len(word)):
		for k in range(d, len(s)):
			if word[i] == s[k]:
				poss.append(s[k])
				d = k + 1
				break
	if poss == word:
		print('YES')
	else:
		print('NO')


import sys

def checker(x):
	target = 'hackerrank'
	l = len(x)
	i = 0
	for i in range(l):
		if target == '':
			break
		if x[i] == target[0]:
			target = target[1:]
	return target
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if checker(s) == '':
		print('YES')
	else:
		print('NO')


import sys

def find_substring_in_string(s, find_in_s):
	pos = -1
	for char in find_in_s:
		pos = s.find(char, pos + 1)
		if pos == -1:
			return False
	return True
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	if find_substring_in_string(s, 'hackerrank'):
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	match = re.match('.*h.*a.*c.*k.*e.*r.*r.*a.*n.*k.*', s)
	if match is not None:
		print('YES')
	else:
		print('NO')


import sys

def is_substring(s1, s2):
	i = 0
	ls1 = len(s1)
	ls2 = len(s2)
	if ls1 > ls2:
		return False
	for j in range(ls2):
		if s1[i] == s2[j]:
			i = i + 1
		if i == ls1:
			return True
	return False
q = int(input().strip())
string = 'hackerrank'
for a0 in range(q):
	s = input().strip()
	if is_substring(string, s):
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	copy = s
	match = 'hackerrank'
	i = 0
	flag = True
	while len(copy) > 0:
		if match[i] in copy:
			ind = copy.index(match[i])
			copy = copy[ind + 1:]
		else:
			print('NO')
			flag = False
			break
		i += 1
		if i >= len(match):
			print('YES')
			flag = False
			break
	if flag == True:
		print('NO')


import sys
q = int(input().strip())
h = 'hackerrank'
for a0 in range(q):
	s = input().strip()
	i = 0
	for ch in s:
		if i < len(h) and h[i] == ch:
			i += 1
	print('YES') if i == len(h) else print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	t = 'hackerrank'
	f = 1
	while f and t:
		i = s.find(t[0])
		if i == -1:
			f = 0
		else:
			t = t[1:]
			s = s[i + 1:]
	if t:
		print('NO')
	else:
		print('YES')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	stck = ['k', 'n', 'a', 'r', 'r', 'e', 'k', 'c', 'a', 'h']
	for i in s:
		if len(stck) == 0:
			break
		if i == stck[-1]:
			stck.pop()
	if len(stck) == 0:
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	w = input().strip()
	flag = True
	for c in 'hackerrank':
		pos = w.find(c)
		if pos >= 0:
			w = w[pos + 1:]
		else:
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


import sys
searched_string = 'hackerrank'
searched_length = len(searched_string)
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	pointer = 0
	found = False
	for c in s:
		if pointer == searched_length:
			found = True
			break
		if c == searched_string[pointer]:
			pointer += 1
	if pointer == searched_length:
		found = True
	if found:
		print('YES')
	else:
		print('NO')


import sys
import re
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	hIndex = s.find('h')
	if hIndex != -1:
		aIndex = s.find('a', hIndex)
		if aIndex != -1:
			cIndex = s.find('c', aIndex)
			if cIndex != -1:
				kIndex = s.find('k', cIndex)
				if kIndex != -1:
					eIndex = s.find('e', kIndex)
					if eIndex != -1:
						rIndex = s.find('r', eIndex)
						if rIndex != -1:
							rIndex = s.find('r', rIndex + 1)
							if rIndex != -1:
								aIndex = s.find('a', rIndex)
								if aIndex != -1:
									nIndex = s.find('n', aIndex)
									if nIndex != -1:
										kIndex = s.find('k', nIndex)
										if kIndex != -1:
											print('YES')
											continue
	print('NO')


import sys
q = int(input().strip())
string = list('hackerrank')
for a0 in range(q):
	s = input().strip()
	j = 9
	for i in range(len(s) - 1, -1, -1):
		if j >= 0:
			if s[i] == string[j]:
				j -= 1
	print('YES' if j < 0 else 'NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	check = list('hackerrank')
	test = ''
	counter = 0
	for letter in range(len(s)):
		if s[letter] == check[counter]:
			test += s[letter]
			if counter == len(check) - 1:
				break
			counter += 1
	if test == 'hackerrank':
		print('YES')
	else:
		print('NO')


import sys
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	tS = list('hackerrank')
	for item in reversed(s):
		if not tS:
			break
		if item == tS[-1]:
			tS.pop()
	if tS:
		print('NO')
	else:
		print('YES')


import sys
import string
q = int(input().strip())
for a0 in range(q):
	flag = 0
	s = input().strip()
	x = 'hackerrank'
	for i in x:
		a = s.find(i)
		s = s[a + 1:]
		if a < 0:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
target = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	i = 0
	for c in s:
		if c == target[i]:
			i += 1
			if i == len(target) - 1:
				break
	if i == len(target) - 1:
		print('YES')
	else:
		print('NO')


import sys
hackchars = ['h', 'a', 'c', 'k', 'e', 'r', 'n', 'k']
hackstring = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	s1 = ''
	for char in s:
		if char in hackchars:
			s1 += char
	hackindex = 0
	count = 0
	while hackindex < len(hackstring):
		if hackstring[hackindex] in s1:
			s1loc = s1.index(hackstring[hackindex]) + 1
			s1 = s1[s1loc:]
			count += 1
		hackindex += 1
	if count == 10:
		print('YES')
	else:
		print('NO')


import sys
T = int(input())
pattern = 'hackerrank'
for t in range(T):
	word = input()
	index = -1
	word_found = True
	for letter in pattern:
		index = word.find(letter, index + 1)
		if index == -1:
			word_found = False
			break
	print('YES' if word_found else 'NO')


import sys
word = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	found = False
	i = 0
	for letter in s:
		if letter == word[i]:
			i += 1
			if i >= len(word):
				found = True
				print('YES')
				break
	if found != True:
		print('NO')


import sys
q = int(input())
h = 'hackerrank'
h_len = len(h)
for _ in range(q):
	i = 0
	str = input()
	str_len = len(str)
	for j in range(str_len):
		if str[j] == h[i]:
			i += 1
		if i == h_len:
			break
	print('YES' if i == h_len else 'NO')


import sys
target = 'hackerrank'
q = int(input().strip())
for a0 in range(q):
	s = input().strip()
	pos = 0
	for char in s:
		if char == target[pos]:
			pos += 1
			if pos == 10:
				break
	print('YES' if pos == 10 else 'NO')