process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// function main() { var q = parseInt(readLine()); for(var a0 = 0; a0 < q; a0++){ var s = readLine(); // your code goes here let word = s.toLowerCase(); let found = word.length > 0 ? true : false; let i = 0; let hackerrank = "hackerrank"; let temp = "hackerrank".split(''); while(word.length > 0 && i < hackerrank.length) { let char = hackerrank.charAt(i); let foundIndex = word.indexOf(char); if (foundIndex === -1) { found = false; } i += 1; word = word.substring(foundIndex + 1, word.length); temp.splice(0, 1); } if (temp.length > 0) { found = false; } console.log(found ? "YES" : "NO"); } }