#578
Bronze II
Blocks
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

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 (1N101\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.

예제 입력 1

6
MOOOOO
OOOOOO
ABCDEF
UVWXYZ
COW
MOO
ZOO
MOVE
CODE
FARM

예제 출력 1

YES
NO
YES
YES
NO
NO
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Bronze II1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.