Under construction

Still being built. Things may change

Food Delivery

Interview

Time limit8sMemory limit1024 MB

Summary
Find the weighted balance point row and column from a grid of food weights.
Level

Easy2 of 10

Topics
Implementation, Matrix, Math
Solved
No attempts yet

Problem

The food delivery service UnterEats delivers food in custom containers designed by the world-famous designer X to raise both the company's brand value and its transport efficiency at the same time.

The container was excellent, but the couriers who actually used it rated it very poorly. It had no handles. Couriers had to support the container from below at just the right balance point, and accidents in which they lost their balance and ruined the food happened often.

UnterEats tried to add handles. When the company consulted X, X became furious and insisted that there could not be anything wrong with the design. X then threatened a lawsuit if the company tried to add handles anyway. Left with no choice, you, a software engineer at UnterEats, are to develop software that computes where to hold the container from the arrangement of the food.

The container has square cells packed in HH rows and WW columns. When the cell in the ii-th row from the top and the jj-th column from the left contains food of weight vi,jv_{i,j}, find a pair of real numbers (r,c)(r,c) that satisfies the following two equations.

∑i,jvi,j(i−r)=0,∑i,jvi,j(j−c)=0\sum_{i,j} v_{i,j}(i-r)=0, \qquad \sum_{i,j} v_{i,j}(j-c)=0

Input

Input consists of at most 50 datasets. Each dataset is given in the following format.

H W
v1,1v1,2...v1,W
v2,1v2,2...v2,W
…
vH,1vH,2...vH,W

The first line contains two integers HH and WW (1≤H,W≤1001 \le H,W \le 100) representing the size of the container. From the second line to the (H+1)(H+1)-th line, each line contains a string of WW digits. The number represented by the digit in row i+1i+1, column jj is vi,jv_{i,j} (0≤vi,j≤90 \le v_{i,j} \le 9). For each dataset, the sum of vi,jv_{i,j} is positive. The end of the input is a line containing two zeros separated by a space.

Output

For each dataset, print rr and cc in that order, separated by a space, on one line. An output is accepted if the absolute error of both rr and cc from the true solution is at most 10−610^{-6}.

Examples1

  1. Example 1

    Input
    3 5
    11111
    11111
    11111
    3 5
    11111
    10111
    11111
    3 5
    12345
    12345
    12345
    0 0
    
    Expected output
    2.0 3.0
    2.0000000000 3.0714285714
    2.0000000000 3.6666666667