#include
using namespace std;
int main()
{
int val =1;
int arr[100][100];
int m ,n;
cin>>m>>n;
for(int i =0;i<m;i++)
{
for(int j =0;j<n; j++)
{
arr[i][j]= val;
val = val+1;
cout<<arr[i][j]<<" ";
}cout<<endl;
}
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]<< ",";
}
}
}cout<<"END"<<endl;
return 0;
}