import scala.io.StdIn object Solution { val hackerrank = List('h', 'a', 'c', 'k', 'e', 'r', 'r', 'a', 'n', 'k') def main(args: Array[String]): Unit = { val q = StdIn.readInt() (0 until q).foreach(i => { val s = StdIn.readLine().toList println(if (contains(s, hackerrank)) "YES" else "NO") }) } def contains(s: List[Char], h: List[Char]): Boolean = h match { case Nil => true case hHead :: hTail => s match { case Nil => false case sHead :: sTail => if (sHead == hHead) contains(sTail, hTail) else contains(sTail, h) } } }