#include <bits/stdc++.h>

using namespace std;

int main(){
    int q;
    cin >> q;
    bool matches = true;
    string hr = "hackerrank";
    unordered_map<char, int> word;
    for( auto c: hr) word[c] = 0;
    for( auto c: hr) word[c] += 1;
  
    for(int a0 = 0; a0 < q; a0++){
        string s;
        cin >> s;
      unordered_map<char, int> char_count;
      for( auto c: s ) char_count[c] = 0;
      for( auto c: s ) char_count[c] += 1;
      for( auto c: s ){
        matches &= (char_count[c] >= word[c]);
      }
      cout << ( matches ? "YES" : "NO" ) << endl;
    }
    return 0;
}