#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<string.h>
using namespace std;


int main() {
    int n;
    scanf("%d",&n);
    while(n--)
    {
        string str;
        cin>>str;
        int i=0;
        int count=0,count1=0;
        int a=-1,b=-1,c=-1,d=-1,e=-1,f=-1,g=-1,h=-1,k=-1,j=-1;
        while(str[i]!='\0')
            {
            if(str[i]=='h')
                a=i;
            else if(str[i]=='a')
                if(i>a && a!=-1)
                b=i;
                else
                {
                count=1;
                break;
                }
            else if(str[i]=='c')
                if(i>b && b!=-1)
                c=i;
                else
                {
                count=1;
                break;
                }
            else if(str[i]=='k')
                if(i>c && c!=-1)
                d=i;
                else
                {
                count=1;
                break;
                }
            else if(str[i]=='e')
                if(i>d && d!=-1)
                e=i;
                else
                {
                count=1;
                break;
                }
            else if(str[i]=='r')
            {
                if(count1==0)
                {if(i>e && e!=-1)
                {f=i;
                 count1=1;
                }
                else
                {
                count=1;
                break;
                }
                }
                else
                    {
                    if(i>f && f!=-1)
                g=i;
                else
                {
                count=1;
                break;
                }
                }
            }
            else if(str[i]=='a')
                if(i>g && g!=-1)
                h=i;
                else
                {
                count=1;
                break;
                }
            else if(str[i]=='n')
                if(i>h && h!=-1)
                k=i;
                else
                {
                count=1;
                break;
                }
            else if(str[i]=='k')
                if(i>k && k!=-1)
                j=i;
                else
                {
                count=1;
                break;
                }
            i++;
            }
        if(count==0)
            printf("NO\n");
        else
            printf("YES\n");
    }
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    return 0;
}