Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

NAJHP - Hippo and Bloody Jungle!

Hippo and his two friends lost their path in a jungle. In this days jungle is most dangerous place. The jungle has lots of tunnels. Also there lived some brutal animals in the dangerous zone(the cell ‘D’). Now Hippo and his two friends want to go to safe places(‘#’) as fast as possible i.e. in minimum times.

In this problem you are given the jungle-map asa grid. Where ‘A’,’B’,’C’ denotes the position of Hippo and his two friends. ’D’ indicates dangerous place. No one can stay this cell.  ‘#’ denotes the safe place. In this grid there are also given some characters (E-Z) which occur more than one and donates if one reaches a tunnel he can go any other tunnel of same character and also any adjacent cell(8-directions). They also can move any adjacent cell from ordinary place. Each move takes 1 unit of time. Is it possible to go all of them to safe places??  If possible then what is the minimum time required.

Input:

Input starts with an integer T (≤ 15), denoting the number of test cases.

Each case starts with a line containing two positive integers H and W; W and H are the numbers of cells in the x and y directions, respectively. W and H are not more than 20.There will be H more lines in the data set, each of which includes W characters. Each character represents the status of a cell as follows.

1) '.' – ordinary place.

2) '#' – safe place

3) 'A', 'B','C' - initial position of Hippo and his friends.

4) 'D' – Dangerous place.

3) 'E-Z' - denote the tunnel.

Output:

For each test case, print the case number and minimum time if it is not possibleto reach all of them into safe position otherwise print “impossible” without quote.

 

 

 

 

Sample:

Input

Output

2

 

5 6

C..E#.

.D....

F..E..

.D..A.

.B.D.F

 

4  4

C.D#

.FDD

A..E

.B.F

Case 1: 4

Case 2: impossible

 

 


Added by:Najmuzzaman
Date:2015-03-13
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ADA95 ASM64 MAWK BC C-CLANG NCSHARP CPP14-CLANG COFFEE D-CLANG D D-DMD DART ELIXIR ERL FANTOM FORTH JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY3 R RACKET RUST SCALA SCM guile SCM qobi CHICKEN SED ST SQLITE SWIFT UNLAMBDA WHITESPACE

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.