import java.util.*;
public class main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int r=sc.nextInt();
        int c=sc.nextInt();
        int mat[][]=new int [r][c];
        if(r<0 || c<0)
         System.out.println("Invalid input");
         return;
        for(int row=0;row<r;row++)
        {
            for( int col=0;col<c;col++)
            {
                mat[row][col]=sc.nextInt();
            }
        }
        for(int row=r-1;row>=0;row--)
        {
            for(int col=c-1;col>=0;col--)
            {
                System.out.print(mat[row][col]+  " ");
            }
            System.out.println();
        }
    }
}