#ABC475F. 矩形涂黑 / Rectangle Filling

矩形涂黑 / Rectangle Filling

Problem Statement

There is a grid with HH rows and WW columns. Let the cell at the ii-th row from the top and jj-th column from the left be denoted as cell (i,j)(i, j).

Each cell of the grid is painted white or black: cell (i,j)(i, j) is white if the jj-th character of SiS_i is ., and black if it is #.

You can perform the following operation at most once.

  • Choose a rectangular region, and paint all cells within that region black. More formally, choose integers h1,h2,w1,w2h_1, h_2, w_1, w_2 satisfying 1≤h1≤h2≤H1 \leq h_1 \leq h_2 \leq H and 1≤w1≤w2≤W1 \leq w_1 \leq w_2 \leq W, and paint cell (h,w)(h, w) black for every pair of integers (h,w)(h, w) satisfying h1≤h≤h2h_1 \leq h \leq h_2 and w1≤w≤w2w_1 \leq w \leq w_2.

Find the number of possible states of the grid that can be obtained. Here, two states of the grid are considered different if there exists a pair of integers (i,j)(i, j) satisfying 1≤i≤H1 \leq i \leq H and 1≤j≤W1 \leq j \leq W such that cell (i,j)(i, j) is painted white in one state and painted black in the other state.

Constraints

  • 1≤H,W1 \leq H, W
  • H×W≤2×105H \times W \leq 2 \times 10^5
  • HH and WW are integers.
  • SiS_i is a string of length WW consisting of . and #.

Input

The input is given from Standard Input in the following format:

  • HH WW
  • S1S_1
  • S2S_2
  • ⋮\vdots
  • SHS_H

Output

Output the answer.

2 3
#..
.##
7

The possible states of the grid obtainable by performing the operation at most once are the following seven:

#.. ##. #.# ### #.. ##. ###
.## .## .## .## ### ### ###
4 1
#
#
#
#
1
5 5
..##.
..#.#
.##.#
....#
##.##
96