### Matrix Again

#### Description:

"In every contest there should be an easy problem about matrices. December Cook-Off is not an exception. Given a matrix A which consists of n rows and m columns, and contains integer numbers. Consider every possible vector v of m elements, such that every 1 vi n. Let value of the vector be product of all Avi, i (1 i m). You are to count the sum of values over all possible vectors v. Input details The first line contains two integers n and m dimensions of the matrix. Then n lines of m integers follow. The jth element of ith line contains Ai, j. Output details Output single integer the answer for the problem modulo 107 + 7, i.e the smallest non-negative integer number r that answer - r is divisible by 107 + 7. Constraints 1 <=n <= 47 1 <=m <= 38 0 <= |Ai, j| <= 100 " Test Case 1 Input (stdin) 2 2 2 4 5 6 Expected Output 70 Test Case 2 Input (stdin) 2 2 1 3 2 4 Expected Output 21

#### Program :

#include<stdio.h>

int main()

{

long long int an,i,j,m,n,ans,mat;

scanf("%lld%lld",&n,&m);

ans=0;

for(i=0;i<n;i++)

{

for(j=0;j<m;j++)

scanf("%lld",&mat[i][j]);

}

ans=1;

for(i=m-1;i>=0;i--)

{

an=0;

for(j=0;j<n;j++)

{mat[j][i]=(mat[j][i]*ans)%10000007;

an=(an+mat[j][i])%10000007;

}

ans=an;

}

if(an<0)

an=an+10000007;

printf("%lld\n",an);

return 0;

}