시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB443100.000%

문제

Danny has a new toy called Ball of Whacks. It's a rhombic triacontahedron (which we all know is a thirty sided polyhedron) made of small pyramid-shaped pieces which look like the following:

Figure C.1: Game piece.

When all $30$ pieces are all put together, they form the object shown in Figure C.2a. Figures C.2b--C.2f show one way to build a rhombic triacontahedron: at the bottom is a petal-shaped section of five pyramids (C.2b --- note that only the base of each pyramid piece is shown); on top of that is a ring of five more pieces (C.2c); on top of that is a larger ring of ten pieces (C.2d), following by a five-piece ring (C.2e) and another petal-shaped section (C.2f). Figure C.3 contains two other views showing how the pieces are connected to one another.

Figure C.2: Construction of a Ball of Whacks.

Figure C.3: Numbering scheme of an assembled Ball of Whacks

Danny has several friends who also own Balls of Whacks, and when they get together$\ldots$ well, balls get whacked. The result are a number of sections of varying size and shape lying on the floor. When it's time to go home, Danny needs to know which sections fit together to make one complete Ball of Whacks. He would like you to help him.

입력

The input file consists of descriptions of three Ball of Whacks sections, each description on a single line. Each description starts with an integer $m$ indicating the number of pyramid-shaped pieces in the section, followed by a set of numbers between $1$ and $30$ indicating the relative alignment of the pyramid pieces in the section, using the numbered locations in diagrams Figure C.2b-C.2f. Each section description starts with a piece in position $1$, though that piece --- along with all other pieces in the section --- may need to be moved in order for all three sections to fit together. The pieces in any section will be connected; i.e., you can get from any one piece in a section to any other by crossing over pieces which share an internal face.

출력

Output either Yes if the three sections can be fit together to get one Ball of Whacks, or No if they cannot be fit together.

예제 입력 1

25 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
3 1 2 3
2 1 2

예제 출력 1

Yes

예제 입력 2

24 1 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 25 26 27 30
5 1 2 3 4 5
1 1

예제 출력 2

No