You took a photo of a building whose equally sized windows are laid out in neat rows and columns. Some of the windows are painted with curious designs. You want to analyze the photo and count how many distinct designs there are.
The photo is a rectangular grid of characters with r rows and c columns. Every window is a rectangle and all windows have the same dimensions. Each cell of a window is either clear (the . character) or painted (the + character). Two windows have the same design if one of them can be rotated by a multiple of 90 degrees and placed on top of the other so that they match exactly. Flipping a window over is not allowed when comparing designs.
Every window is framed by a single line of brick cells (the # character). There is exactly one row of # characters between two consecutive window rows, before the first window row, and after the last window row. In the same way there is exactly one column of # characters between two consecutive window columns, before the first window column, and after the last window column. The number of window rows and the number of window columns are arbitrary, and so are the window dimensions. A window consists of at least one cell, and all windows in the photo have the same dimensions.
Find the number of different window designs in the photo.