// am not able to find error with this code, none of the test cases are running.
import java.util.*;
public class Main {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();
int n=sc.nextInt();
int[][] arr=new int[10][10];
if(n<=10 && n>0 && m<=10 && m>0)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
arr[i][j]=sc.nextInt();
}
}
for(int i=0;i<n;i++)
{
if(i%2==0)
{
for(int j=0;j<m;j++)
{
System.out.print(arr[j][i]+", “);
}
}
else
{
for(int j=m-1;j>=0;j–)
{
System.out.print(arr[j][i]+”, “);
}
}
}
System.out.print(” END");
}
}
}