## BLINDESC - Blind Escape II

Illidan Stormage, the blind Warcraft hero is thrown in a maze for punishment. Being a blind hero, he cannot see anything but he can sense which direction is North, East, South and West.

Assume that the maze is laid out on a grid, and each grid location is either blocked or free or contains a demon. He has four possible moves: North, East, South, and West. Illidan starts from a free location at time t=0, and his goal is to kill all the demons within time T. Illidan kills a demon immediately (takes 0 unit of time) whenever he lands on a grid location containing a demon, however making a move to an adjacent cell takes exactly 1 unit of time. If Illidan attempts to move out of the grid or attempts to move to an obstacle, he will stay in his current location but it will still cost him 1 unit of time. When Illidan kills the last demon, he is immediately freed from the maze but if he fails to kill all the demons within time T, he will be trapped in the maze for eternity.

Keep in mind that Illidan is blind, so he may get confused while making a move. To avoid all this chaos, he decides to follow a rather simple strategy. Before he starts his journey to hunt and kill all the demons, he selects four real numbers: PN, PE, PS and PW denoting the probability to move North, East, South and West respectively. No matter where he is, he will always attempt to move North with probability PN, East with probability PE, South with probability PS, and West with probability PW.

Given the description of the maze, the location of all the demons, Illidanâ€™s starting position and the probabilities of each move, calculate the probability that Illidan will be able to kill all the demons before the time runs out.

Assume the grid will be of dimensions N x M and will contain K demons.

### Input

The first line of the input contains an integer Q, denoting the number of test cases. Then the description of Q test cases follow. The first line of every test case will start with a blank line.

The second line contains three space separated integers, N, M and T, denoting the number of rows, the number of columns of the grid and the time by which Illidan needs to kill all the demons respectively. The third line contains four space separated real numbers PN, PE, PS and PW in that order. All these numbers will contain at most 2 digits after the decimal point.

Each of the next N lines will contain exactly M characters on each line describing the grid. The grid will only consist of the characters . @ # and *.

. indicates a free cell.

@ indicates Illidanâ€™s starting position which is also a free cell and will occur exactly once.

# denotes an obstacle.

* denotes the location of a demon, there can be at most one demon in a cell.

### Constraints

• 1 ≤ Q ≤ 5
• 1 ≤ N, M ≤ 8
• 1 ≤ T ≤ 16777216
• 1 ≤ K ≤ 3
• PN + PE + PS + PW = 1
• ### Output

For each test case, print the probability of Illidan escaping the maze in a single line. Error less than 10-6 will be ignored.

### Sample Input

```3

1 2 3
0 0.5 0 0.5
@*

1 8 64
0 0.5 0 0.5
@......*

8 8 10000000
0.05 0.25 0.45 0.25
##....#.
.##.....
.*#.##..
.##..*#.
...###..
.#.#....
.#.#.#..
@#.*.#..
```

### Sample Output

```0.875000000000
0.693211582717
0.157323987423
```

### Credits

Problem name and story inspired by LightOJ 1426 - Blind Escape

Or if you prefer a not so blind version SPOJ NBLINDESC- Not So Blind Escape