#!/bin/python3 import sys from collections import deque def test(s): word = deque(['k','n','a','r','r','e','k','c','a','h']) for i in range(0,len(s)): temp_char = s[i] poped_char = word.pop() if(not(poped_char is temp_char)): word.append(poped_char) if(not word): return "YES" return "NO" q = int(input().strip()) for a0 in range(q): s = input().strip() # your code goes here print(test(s))