CF1873C.Target Practice

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Target Practice

A 10×1010 \times 10 target is made out of five "rings" as shown. Each ring has a different point value: the outermost ring — 1 point, the next ring — 2 points, ..., the center ring — 5 points.

Vlad fired several arrows at the target. Help him determine how many points he got.

Input

The input consists of multiple test cases. The first line of the input contains a single integer tt (1t10001 \leq t \leq 1000) — the number of test cases.

Each test case consists of 10 lines, each containing 10 characters. Each character in the grid is either X (representing an arrow) or . (representing no arrow).

Output

For each test case, output a single integer — the total number of points of the arrows.

Note

In the first test case, there are three arrows on the outer ring worth 1 point each, two arrows on the ring worth 3 points each, and two arrows on the ring worth 4 points each. The total score is 3×1+2×3+2×4=173 \times 1 + 2 \times 3 + 2 \times 4 = 17.

In the second test case, there aren't any arrows, so the score is 00.

Samples

4
X.........
..........
.......X..
.....X....
......X...
..........
.........X
..X.......
..........
.........X
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
....X.....
..........
..........
..........
..........
..........
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
17
0
5
220

在线编程 IDE

建议全屏模式获得最佳体验