← Home
```go
package main

import "fmt"

func main() {
	var password string
	fmt.Scan(&password)

	var n int
	fmt.Scan(&n)

	hasFirst := false  // Represents if there is a word ending with password[0]
	hasSecond := false // Represents if there is a word starting with password[1]
	found := false     // Represents if the password exists exactly in the list

	for i := 0; i < n; i++ {
		var word string
		fmt.Scan(&word)

		if word == password {
			found = true
		}
		if word[1] == password[0] {
			hasFirst = true
		}
		if word[0] == password[1] {
			hasSecond = true
		}
	}

	if found || (hasFirst && hasSecond) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
```