P17997 [GCPC 2021] Looking for Waldo

Description

You may know the game *Where is Waldo?*. In this game you need to find a person named Waldo in a crowd of people. This problem is kind of similar. You need to find an axis-aligned rectangle of minimal area which contains the letters `W`, `A`, `L`, `D` and `O` and those letters are hidden in a crowd of other letters. ![](https://cdn.luogu.com.cn/upload/image_hosting/7j4maqc0.webp) Illustration of the second sample case.

Input Format

The input consists of: - One line with two integers $h$ and $w$ $(1\leq h, w \leq 10^5$, $h\cdot{}w \leq 10^5)$, the height and width of the grid of letters. - $h$ lines, each with $w$ upper case letters `A`-`Z`, the grid of letters.

Output Format

Output the area of the smallest axis-aligned rectangle which contains at least one of each of the letters `W`, `A`, `L`, `D` and `O`. If there is no rectangle containing those letters, output `impossible`.