i suggest you just write ascending numbers in binary format, then all rows or columns are unique. think about how many rows and digits you need. this way you could produce e.g.
0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 ...
the minimum width of your matrix is then given by nextpow2 of your number of rows, but if you need a broader matrix you are free to just use more bits