#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define mp(first, second) make_pair(first, second) typedef unsigned long long ul; typedef long long ll; typedef pair ii; typedef vector vii; typedef vector vi; bool LCS(string str1, string str2) { vector dp(str1.size() + 1, vi(str2.size() + 1)); for (int x = 1; x < dp.size(); x++) { for (int i = 1; i < dp[0].size(); i++) { if (str1[x - 1] == str2[i - 1]) { dp[x][i] = dp[x - 1][i - 1] + 1; } else { dp[x][i] = max(dp[x - 1][i], dp[x][i - 1]); } } } if (dp[str1.size()][str2.size()] == 10) { return true; } return false; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int q; cin >> q; string str1 = "hackerrank"; for (size_t i = 0; i < q; i++) { string str2; cin >> str2; bool ans = LCS(str1, str2); if (ans) { cout << "YES" << endl; } else { cout << "NO" << endl; } } //while (true) //{ // //} return 0; }