class Solution
{
//Function to add two matrices.
static int[][] sumMatrix(int A[][], int B[][])
{
int n = A.length, m = A[0].length;
int res[][] = new int[0][0];
//Check if two input matrix are of different dimensions
if(n != B.length || m != B[0].length)
return res;
res = new int[n][m];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
res[i][j] = A[i][j] + B[i][j];
return res;
}
}