#P8185. [USACO22FEB] Blocks B

[USACO22FEB] Blocks B

题目描述

In an effort to improve her vocabulary, Bessie the cow has obtained a set of four wooden blocks, each one a cube with a letter of the alphabet written on each of its six sides. She is learning how to spell by arranging the blocks in a row so the letters on top of the blocks spell words.

Given the letters on each of Bessie's four blocks, and a list of words she would like to spell, please determine which of words on her list she will be able to spell successfully using the blocks.

输入格式

The first line of input contains NN (1N10)(1\le N\le 10), the number of words that Bessie would like to spell. The next four lines each contain a string with six uppercase letters, representing the letters on the six sides of one of Bessie's blocks. The next NN lines contain the NN words Bessie would like to spell. Each of these is between 1 and 4 uppercase letters long.

输出格式

For each word on Bessie's list, output YES if she is able to spell it using the blocks and NO otherwise.

题目大意

题目描述

为了提高词汇量,母牛贝西得到了一套四块木块,其中每块都是一个立方体,六面各写着一个字母。她正在通过将木块排成一排使得木块顶部的字母拼出单词来学习拼写。

给定 Bessie 的四个木块上的字母,以及她想拼写的单词列表,请确定列表中哪些单词可被她使用木块成功拼写。

输入格式

输入的第一行包含 N(1N10)N (1\leq N\leq 10),为 Bessie 想要拼写的单词数。接下来的四行每行包含一个带有六个大写字母的字符串,表示 Bessie 的一个块的六个侧面上的字母。接下来的 NN 行包含 Bessie 想要拼写的 NN 个单词。其中每一个的长度在 1144 个大写字母之间。

输出格式

对于 Bessie 列表中的每个单词,如果她能够使用木块拼写,则输出 YES,否则输出 NO。

样例解释

在本例中,Bessie 可以拼写 COW、ZOO 和 MOVE。 不幸的是,她不能拼写 MOO,因为唯一带有 M 的木块也不能用于 O。她不能拼写 FARM,因为没有字母 R 的木块。她不能拼写 CODE,因为 C、D 和 E 都属于同一个木块。

6
MOOOOO
OOOOOO
ABCDEF
UVWXYZ
COW
MOO
ZOO
MOVE
CODE
FARM
YES
NO
YES
YES
NO
NO

提示

【样例解释】

In this example, Bessie can spell COW, ZOO, and MOVE. Sadly, she cannot spell MOO, since the only block with an M cannot also be used for an O. She cannot spell FARM since there is no block with a letter R. She cannot spell CODE since the C, D, and E all belong to the same block.