You probably know the game Fifteen Puzzle. Here, instead of field 4 by 4 and numbered tiles, we have field by ,  red tiles and  blue tiles.
A move is denoted by the uppercase initial of the direction (Left, Right, Up, Down) in which the tile is slid, e.g. starting from configuration (S), by the sequence LULUR we reach the configuration (E):
For each path, its checksum is calculated by pseudocode:
where is the ASCII value of the -th letter in the move sequence and the ASCII values for the moves are:
For the sequence LULUR given above, the checksum would be .
Now, starting from given configuration (S), find all shortest ways to reach given configuration (E).
What is the sum of all checksums for the paths having the minimal length?
First line contains the only integer .
Next lines contain configuration (S).
Next lines contain configuration (E).
Blue, red and white tiles are denoted by letters B, R and W respectively.
Print the only number the total sum of all checksums modulo .