import java.io.*; import java.util.*; import java.text.*; 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(); boolean matched = false; // Initialize our set of characters to match and its index char[] matchChars = {'k', 'n', 'a', 'r', 'r', 'e', 'k', 'c', 'a', 'h'}; int matchCharsIndex = 9; // Match characters until either we run out of characters to match (success) or // input characters to be matched (failure) CharacterIterator iter = new StringCharacterIterator(s); for (char ch = iter.first(); ch != CharacterIterator.DONE; ch = iter.next()) { if (ch == matchChars[matchCharsIndex]) { matchCharsIndex -= 1; if (matchCharsIndex < 0) { matched = true; break; } } } // Output our result System.out.println(matched ? "YES" : "NO"); } } }