PivotOJ

Ball of Whacks

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC ECNA 2021-2022BOJ 24557

문제

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 3030 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 mm indicating the number of pyramid-shaped pieces in the section, followed by a set of numbers between 11 and 3030 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 11, 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
출력
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
출력
No
코드를 제출하려면 로그인하세요.