#include #include #include #include using namespace std; int main() { string s, word; cin >> s; int n; cin >> n; unordered_set words; for (int i = 0; i < n; ++i) { cin >> word; words.insert(word); } vector is_human(s.length() + 1, false); is_human[0] = true; for (int j = 6; j <= s.length(); ++j) { for (int i = max(0, j - 10); i < j - 5; ++i) { if (words.count(s.substr(i, j - i)) && is_human[i]) { is_human[j] = true; break; } } } cout << (is_human[s.length()] ? "yes" : "no") << endl; }