It gives the correct output when compile but throwing error while submitting
Scanner s = new Scanner(System.in);
int m = s.nextInt();
int n = s.nextInt();
int[][] arr = new int[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
arr[i][j] = s.nextInt();
}
}
for (int i = 0; i < m; i++) {
if(i % 2 == 0) {
for (int j = 0; j < n; j++) {
System.out.print(arr[j][i] + ", ");
}
}else {
for(int j = n-1; j >= 0; j--) {
System.out.print(arr[j][i] + ", ");
}
}
}
System.out.println("END");