Probability on matrix


Suppose there is a 2016 x 2016 matrix. In how many ways can you fill all the cells with integers so that if you multiply all the entries in any particular row or column, the result is always 2? As the result is large, find the result modulo 2017. That means if the number of ways can be written in the form 2017k + r , find r