ABCPATH  ABC Path
You will be given a 2dimensional grid of letters. Find the length of the longest path of consecutive letters, starting at 'A'. Paths can step from one letter in the grid to any adjacent letter (horizontally, vertically, or diagonally).
For example, in the following grid, there are several paths from 'A' to 'D', but none from 'A' to 'E':
One such path is:
Input
Each test case will start with a line contains two integers H, W the height and width of the grid respectively 1 <= H, W <= 50. Then H lines follow each of W uppercase letters only. Input terminates with H = 0 and W = 0.
Output
For each test case print “Case C: X” without quotes where C is the case number starting with 1 and X is the solution.
Example
Sample Input: 4 3 ABE CFG BDH ABC 0 0 Sample Output: Case 1: 4
hide comments
adiupa1234:
20220903 04:08:33
We have to only consider the path starting with 'A'. I wasted time as didn't read it correctly. 

winston_6115:
20220710 13:35:39
Don't bother to thank me :)


taejin_101:
20220620 18:36:00
Number of test cases are not given but at the end of all test cases it will give h = 0 and w = 0


vibhu_gods0n:
20220517 00:00:33
It's Input Format is so confusing


aman2300:
20220305 08:35:18
F for me got wrong answer on 1 row 1 column for non A, wrong intialization


tengai_shinsei:
20220226 10:28:28
<p>AC in one shot!!!!!</p> 

aman440:
20220208 19:37:49
AC in one go :)


darksparrow123:
20220117 13:45:16
zoom AC in one go :)


md__talha__007:
20220116 09:27:19
Do check case in which 'A' is not present. I got 2 WA's due to ths case and wasted my 30 min in this. 

mahbubkuet08:
20211128 19:23:46
At first got TLE. Then used memoization. AC 
Added by:  Ali Arous 
Date:  20111105 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  FCIS Local Contest 2012 