Bunch of Paper

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

There are NN sheets of paper, enumerated by sequential integers from 11 to NN. Each sheet has KK integers written on it, so ii-th sheet contains the integers v_i,1,v_i,2,,v_i,Kv\_{i,1}, v\_{i,2}, \ldots, v\_{i,K}.

Then we choose one integer from each sheet and create the sequence a_ia\_i, where ii-th integer is chosen from ii-th sheet of paper. There are KNK^N ways to make such a sequence. How many of them are non-decreasing? A sequence is non-decreasing if a_ia_i+1a\_i \le a\_{i+1} for all 1iN11 \le i \le N-1.

The answer may be too large, so print it modulo 109+710^9 + 7.

입력

The first line of the input contains two integers NN and KK (1N1001 \le N \le 100, 1K1041 \le K \le 10^4). The ii-th of the following NN lines contains KK integers v_i,1,v_i,2,,v_i,Kv\_{i,1}, v\_{i,2}, \ldots, v\_{i,K} (1v_i,1<v_i,2<<v_i,K1091 \le v\_{i,1} < v\_{i,2} < \ldots < v\_{i,K} \le 10^9).

출력

Print the number of non-decreasing sequences, modulo 109+710^9 + 7.