You are given an N by N grid paper. Initially every cell is white, and some cells have been colored black.
You may choose one rectangular region whose sides follow the grid lines. If every cell inside the chosen rectangle is black and the rectangle contains at least two cells, it is called a black rectangle.

The three rectangles on the left are not black rectangles. Rectangle 1 contains one white cell, and rectangle 2 contains only one cell. The three rectangles selected on the right are all black rectangles.
Given the colored grid, count the number of ways to choose two black rectangles so that they do not share any cell.
The first line contains an integer N. (2 <= N <= 1000)
Each of the next N lines gives the colors of one row of the grid. C means black, and B means white.
Print the number of ways to choose two black rectangles with no shared cell, modulo 10007.