import java.util.*;
public class Main {
public static void printWave(int[][] arr) {
for (int row = 0; row < arr.length; row++) {
if(row%2==0) {
for (int col = 0; col < arr.length; col++) {
System.out.print(arr[row][col]+", “);
}
}
else {
for (int col = arr.length-1 ; col >= 0; col–) {
System.out.print(arr[row][col]+”, ");
}
}
}
System.out.println(“END”);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// enter no of rows
int rows = sc.nextInt();
int cols = sc.nextInt();
int[][] arr = new int[rows][cols];
for (int row = 0; row < arr.length; row++) {
// enter size for coloum row 0 , 1 , 2 ,
// enter value for colom 0,1,2,3
for (int col = 0; col < cols; col++) {
arr[row][col] = sc.nextInt();
}
}
printWave(arr);
}
}