//even tough my code is gets correctly compiled
//but is showing run error when submitted…
#include<bits/stdc++.h>
using namespace std;
int arr[100][100],m,n;
int main(){
cin>>m>>n;
if(m<1 || m>10 || n<1 || n>10)
exit(0);
for(int row=0;row<m;row++)
for(int col=0;col<n;col++)
cin>>arr[row][col];
for(int col=0;col<n;col++){
if(col%2==0){
for(int row=0;row<m;row++)
cout<<arr[row][col];
}
else
for(int row=m-1;row>=0;row++)
cout<<arr[row][col];
}
return 0;
}