op = input()
total = 0

considerados = (
    (11, 11), (11, 10), (11, 9), (11, 8), (11, 7), (11, 6), (11, 5),
    (11, 4), (11, 3), (11, 2), (11, 1), (10, 11), (10, 10), (10, 9),
    (10, 8), (10, 7), (10, 6), (10, 5), (10, 4), (10, 3), (10, 2),
    (9, 11), (9, 10), (9, 9), (9, 8), (9, 7), (9, 6), (9, 5),
    (9, 4), (9, 3), (8, 11), (8, 10), (8, 9), (8, 8), (8, 7),
    (8, 6), (8, 5), (8, 4), (7, 11), (7, 10), (7, 9), (7, 8),
    (7, 7), (7, 6), (7, 5), (6, 11), (6, 10), (6, 9), (6, 8),
    (6, 7), (6, 6), (5, 11), (5, 10), (5, 9), (5, 8), (5, 7),
    (4, 11), (4, 10), (4, 9), (4, 8), (3, 11), (3, 10), (3, 9),
    (2, 11), (2, 10), (1, 11),
)

for i in range(12):
    for j in range(12):
        a = float(input())
        if (i, j) in considerados:
            total += a

if op == "S":
    print("{:.1f}".format(total))
else:
    print("{:.1f}".format(total / 66))

op = input()
total = 0

considerados = (
    (11, 11), (11, 10), (11, 9), (11, 8), (11, 7), (11, 6), (11, 5),
    (11, 4), (11, 3), (11, 2), (11, 1), (10, 11), (10, 10), (10, 9),
    (10, 8), (10, 7), (10, 6), (10, 5), (10, 4), (10, 3), (10, 2),
    (9, 11), (9, 10), (9, 9), (9, 8), (9, 7), (9, 6), (9, 5),
    (9, 4), (9, 3), (8, 11), (8, 10), (8, 9), (8, 8), (8, 7),
    (8, 6), (8, 5), (8, 4), (7, 11), (7, 10), (7, 9), (7, 8),
    (7, 7), (7, 6), (7, 5), (6, 11), (6, 10), (6, 9), (6, 8),
    (6, 7), (6, 6), (5, 11), (5, 10), (5, 9), (5, 8), (5, 7),
    (4, 11), (4, 10), (4, 9), (4, 8), (3, 11), (3, 10), (3, 9),
    (2, 11), (2, 10), (1, 11),
)

for i in range(12):
    for j in range(12):
        a = float(input())
        if (i, j) in considerados:
            total += a

if op == "S":
    print("{:.1f}".format(total))
else:
    print("{:.1f}".format(total / 66))
