In a board there are golden coins and some traps. There are also some pieces: bishops and knights, which move according to chess rules. The pieces can move as many times as you wish, and can cross any square that does not have a trap, even if occupied by another piece. Coins dissapear when some piece picks them up.
Write a program that prints the total number of coins that can be picked up.
Input includes several cases. Each case consists of a line with
and
,
followed by
lines with
characteres each one. A ‘B’ indicates a bishop. A
‘K’ indicates a knight. A ‘T’ indicates a
trap. A dot indicates an empty square. A digit indicates a number of
golden coins. Both
and
are between 1 and 200.
For each case, print a line with the number of golden coins that can be picked up.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T11:40:37.869Z
© Jutge.org, 2006–2026.
https://jutge.org