# Baekjoon-15898-피아의 아틀리에

Python으로 풀 수 없는 문제!!

import sys
from itertools import permutations, product

def rot(arr):
# rotate 90 degree CCW
new_arr = []
for i in range(4):
line = []
for j in range(4):
line.append(arr[j][3-i])
new_arr.append(line)
return new_arr

n = int(input())
put_dict = {k:[] for k in range(n)} # values, colors
for i in range(n):
vals,colors = [],[]
for _ in range(4):
line = list(map(int,input().split()))
vals.append(line)
for _ in range(4):
line = list(input().split())
colors.append(line)
rots = []
for _ in range(4): # rotation
vals,colors = rot(vals), rot(colors)
rots.append([vals,colors])
put_dict[i] = rots

for i in range(4):
for j in range(4):
total[0][i+dx][j+dy] += arr[0][i][j]
total[0][i+dx][j+dy] = max(min(total[0][i+dx][j+dy],9),0)
total[1][i+dx][j+dy] = total[1][i+dx][j+dy] if arr[1][i][j]=='W' else arr[1][i][j]

score_dict = {
'R': 7,
'B': 5,
'G': 3,
'Y': 2,
'W': 0
}
def calResult(total):
result = 0
for i in range(5):
for j in range(5):
result += total[0][i][j] * score_dict[total[1][i][j]]

return result

loc_dict = [[0,0],[0,1],[1,0],[1,1]]
max_value = 0