#P1202C. You Are Given a WASD-string...
You Are Given a WASD-string...
Description
You have a string — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
- 'W' — move one cell up;
- 'S' — move one cell down;
- 'A' — move one cell left;
- 'D' — move one cell right.
Let be the grid of minimum possible area such that there is a position in the grid where you can place the robot in such a way that it will not fall from the grid while running the sequence of commands . For example, if then is the grid:
- you can place the robot in the cell ;
- the robot performs the command 'D' and moves to ;
- the robot performs the command 'S' and moves to ;
- the robot performs the command 'A' and moves to ;
- the robot performs the command 'W' and moves to ;
- the robot performs the command 'W' and moves to ;
- the robot performs the command 'A' and moves to ;
- the robot performs the command 'W' and moves to .

You have extra letters: one 'W', one 'A', one 'S', one 'D'. You'd like to insert at most one of these letters in any position of sequence to minimize the area of .
What is the minimum area of you can achieve?
The first line contains one integer () — the number of queries.
Next lines contain queries: one per line. This line contains single string (, ) — the sequence of commands.
It's guaranteed that the total length of over all queries doesn't exceed .
Print integers: one per query. For each query print the minimum area of you can achieve.
Input
The first line contains one integer () — the number of queries.
Next lines contain queries: one per line. This line contains single string (, ) — the sequence of commands.
It's guaranteed that the total length of over all queries doesn't exceed .
Output
Print integers: one per query. For each query print the minimum area of you can achieve.
Note
In the first query you have to get string .
In second and third queries you can not decrease the area of .