


If no such number is present, return -1.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘2T’ lines represent the ‘T’ test cases.
The first line of each test case contains ‘M’ and ‘N’, denoting the number of rows and columns, respectively.
The second line of each test case contains ‘M’ * ’N’ space-separated integers representing the elements of the 2D array 'MATRIX'.
For each test case, return (i * i + j * j) value for elements in which the sum of cube of digits of the element is equal to the element itself, where 'i' is the row number from ‘0’ to ‘M' - 1, and 'j' is the column number from ‘0’ to ‘N’ - 1.
You are not required to print the output, it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= M <= 100
1 <= N <= 50
1 <= ELEMENT <= 10^9
Time limit: 1 second
The idea is to traverse the matrix of size M x N. For each element in the matrix, we find the sum of the cube of their digits recursively. If the sum of the cube of digits is equal to the element itself, calculate (i*i + j*j).
The idea is to traverse the matrix of size M x N. For each element in the matrix, we find the sum of the cube of their digits. If the sum of the cube of digits is equal to the element itself, calculate (i*i + j*j).
3. Add(i*i + j*j) to our answer vector/list, where ‘i’ is the row index and ‘j’ is the column index.
4. At last, return the answer list/vector if the list is not empty otherwise return list having only 1 element which is -1.