시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 3 1 1 33.333%

문제

백승환은 레고를 좋아한다. 레고를 쌓은 모습이 2가지 각도에서 주어졌을 때, 그렇게 만드는 경우의 수는 총 몇 가지가 있는지 구하는 프로그램을 작성하시오.

이 문제에서 승환이는 오직 2*2크기의 블럭만 사용한다. 하지만, 이 블럭은 흰색 (W), 회색 (G), 검정색 (B) 과 같이 총 3가지 색상이 있다. 승환이는 이 세가지 색상의 블럭을 무수히 많이 가지고 있다. 승환이는 6*6크기의 보드에 레고를 꼽을 것이다. 모든 블럭은 보드의 모서리에 평행해야 하고, 보드의 바깥으로 나가면 안된다. 그리고 블럭은 떠있을 수 없다.

가장 왼쪽은 가능한 경우다. 한 블럭이 다른 블럭 위에 있기 때문이다. 하지만, 가운데는 블럭이 떠있기 때문에 불가능한 경우다. 오른쪽은 6*6 보드를 넘어가므로 불가능한 경우다.

입력

입력의 첫째 줄에 H가 주어진다. H는 승환이가 만드려고 하는 것의 높이이다. 다음 H개의 줄에는 6개의 문자가 주어진다. 이것은 승환이가 만든 것을 한 쪽에서 봤을 때 (밑의 Hint 그림에서 A) 이다. 모든 문자는 W, G, B 또는 .이다. W, G, B는 블럭의 색상이고, .은 빈 공간이다. 이 문제에서 각 블럭의 깊이를 예측할 수 없는 것을 예상하고 문제를 풀어야 한다. 따라서 ,같은 색상이 인접해 있다고 해도, 같은 높이에 있는 블럭이 아닐 수 있다. 그 다음 H줄에는 그림 상에서 B에 해당하는 곳에서 본 블럭의 모양이 주어진다.

출력

첫째 줄에 문제의 정답을 출력한다. 이 때, 어떤 두 가지 모양이 있다고 할 때, 하나를 A, 하나를 B라고 하자. 이 때 B를 거울 대칭이나 회전을 해서 A를 만들 수 있다고 하면, 두 가지 모두 다른 경우로 세야 한다. 정답은 64비트 인트형에 항상 포함된다.

예제 입력 1

2
WWGG..
.BB.WW
.WGG..
WWGG..

예제 출력 1

6

힌트

W3sicHJvYmxlbV9pZCI6IjI0Mj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