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 var test = 'hackerrank'; var currIdx = 0; for (var i = 0; i < s.length; i++) { // Break out of loop if remaining length of test is greater than remaining length of string if (test.length - currIdx > s.length - i) { break; } if (s[i] === test[currIdx]) { currIdx++; } } if (currIdx === test.length) { console.log('YES'); continue; } console.log('NO'); } }