SP3894 BOBALLS - Bouncing Balls

Description

Consider a grid having NxM squares. The top left square is (0,0) and the bottom right is (N-1,M-1). Each square in the grid is either occupied by a platform or has a number written on it. Two balls are released from the top of the grid (from locations (0,Y1) and (0,Y2), 0

Input Format

The first line contains the number of test cases. The first line for each test case consists of N and M. Lines 2..N+1 for each test case consist of M characters each. Each character is either a digit from 0 to 9, or the letter 'P'.

Output Format

The maximum expected score accurate upto 4 decimal places.