Company: Media Net .
Difficulty: medium
Help Your Master 2 Problem Description GOAT-master got arrested in a police chase. He is trying to escape the high-tech prison he is held captive in. He needs a pass-code P for disabling all the cameras in order to escape. Pass-code is the solution of matrix problem given below. Help him finding the pass-code. You are given a matrix of order N x N . Each cell in a matrix has a value A i,j (0<=i,j< N ), which is either positive or equal to -1 (representing blocked cell). Cells which are not blocked have distinct values. You can traverse from a cell in any direction (up, down, left or right), if there is no blockage. For any cell A i,j , sed-value S i,j is defined as sum of values of cells A x,y which are multiple of A i,j , but not reachable from A i,j . For blocked cells, sed-value is -1. Pass-code P is sum of sed-values of all the cells, modulo 1000000007. Constraints 1 <= N <= 1e3 1 <= A[i][j] <= 1e6 A[i][j] = -1 for blocked cells only Input Format First argument is