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.
Illustration of the second sample case. The input consists of:
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.
5 5ABCDEFGHIJKLMNOPQRSTVWXYZ
25
5 10ABCDEABCDEFGHIJFGHIJKLMNOKLMNOPQRSTPQRSTVWXYZVWXYZ
20
5 10WAALDLODOWAWWLAOODOWLOLADOWALOADALLLWWOLWWOOAAAALO
5
2 3WALTER
impossible
| Название |
|---|


