import java.util.Random;
public class Zadaca {

    public static void main(String[] args) {
        int[][] mat = new int[5][5];
        Random random = new Random();
        for(int i = 0; i < 5; i++) {
            for(int j = 0; j < 5; j++) {
                mat[i][j] = random.nextInt(10);
            }
        }

        for(int i = 0; i < 5; i++) {
            for(int j = 0; j < 5; j++) {
                System.out.print(mat[i][j] + " ");
            }
            System.out.println();
        }

       for(int j = 0; j < 5; j++) {
        int product = 1;
        for(int i = 0; i < 5; i++) {
            product *= mat[i][j];
        }
        System.out.println(product);
       }

    }
    
}
