import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private Node first; // top of stack (most recently added node) private int N; // number of items private class Node { // nested class to define nodes char item; Node next; } public boolean isEmpty() { return first == null; } // Or: N == 0. public int size() { return N; } public void push(char item) { // Add item to top of stack. Node oldfirst = first; first = new Node(); first.item = item; first.next = oldfirst; N++; } public char pop() { // Remove item from top of stack. char item = first.item; first = first.next; N--; return item; } 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(); String word="knarrekcah"; Solution a=new Solution(); for(int i=0;i<10;i++) { a.push(word.charAt(i)); } for(int i=0;i0)&&(a.first.item == (s.charAt(i)))) a.pop(); } if(a.N == 0) System.out.println("YES"); else System.out.println("NO"); } } }