import java.util.*; public class _10830 { static int MOD = 1000; static void print_mat(int[][] M, int N) { for (int[] row : M) { for(int i=0; i