Unlocking the Machine Room


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

In an effort to make access to the UCC machine room more accessible than ever James has installed a new voice-activated lock on its door. The Backstreet Boys' Reunion Tour has hit this year's budget and so the installed lock can only recognize a password two English letters in length.

The Cameron Hall pet goose (Gozz) wants access to the machine room and steal some sensible information because sometimes geese be like that. Gozz can honk several (not necessarily distinct) two-letter words one after another to pronounce a string containing the password as a substring. As an agent of chaos yourself, tell Gozz if they are able to unlock the machine room in this way or not.

Input Specification

The first line contains the machine room password as two lowercase English letters

The second line contains a single integer \(n (1 \leq n \leq 100)\), the number of words Gozz can honk.

The next \(n\) lines contain two lower English letters each, representing the words Gozz knows. These words will be distinct.

Output Specification

Print "HONK" if Gozz can honk several words forming a string that contains the password and "NO" otherwise.

Sample Input 1

oo
2
go
oz

Sample Output 1

HONK

Sample Input 2

hp
2
ht
tp

Sample Output 2

NO

Comments

There are no comments at the moment.