Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

В условии задачи недавно были сделаны правки. Просмотреть изменения.

×
C. Kamal-ol-molk's Painting

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputRumors say that one of Kamal-ol-molk's paintings has been altered. A rectangular brush has been moved right and down on the painting.

Consider the painting as a *n* × *m* rectangular grid. At the beginning an *x* × *y* rectangular brush is placed somewhere in the frame, with edges parallel to the frame, (1 ≤ *x* ≤ *n*, 1 ≤ *y* ≤ *m*). Then the brush is moved several times. Each time the brush is moved one unit right or down. The brush has been strictly inside the frame during the painting. The brush alters every cell it has covered at some moment.

You have found one of the old Kamal-ol-molk's paintings. You want to know if it's possible that it has been altered in described manner. If yes, you also want to know minimum possible area of the brush.

Input

The first line of input contains two integers *n* and *m*, (1 ≤ *n*, *m* ≤ 1000), denoting the height and width of the painting.

The next *n* lines contain the painting. Each line has *m* characters. Character 'X' denotes an altered cell, otherwise it's showed by '.'. There will be at least one altered cell in the painting.

Output

Print the minimum area of the brush in a line, if the painting is possibly altered, otherwise print - 1.

Examples

Input

4 4

XX..

XX..

XXXX

XXXX

Output

4

Input

4 4

....

.XXX

.XXX

....

Output

2

Input

4 5

XXXX.

XXXX.

.XX..

.XX..

Output

-1

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/27/2020 23:02:53 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|