#C4063. Rotate Books on Layers
Rotate Books on Layers
Rotate Books on Layers
In this problem, you are given ( n ) layers of books, each layer contains ( k ) books represented as integers. Your task is to rotate each layer to the right by one position. For a given layer of books ( [a_1, a_2, \dots, a_k] ), the rotated layer should be ( [a_k, a_1, a_2, \dots, a_{k-1}] ).
For example, if we have a single layer with books [1, 2, 3], after rotation the layer becomes [3, 1, 2]. Your solution should read the input from standard input and write the output to standard output.
inputFormat
The input is read from standard input.
The first line contains two integers ( n ) and ( k ) separated by a space, where ( n ) is the number of layers and ( k ) is the number of books in each layer.
This is followed by ( n ) lines, each containing ( k ) integers separated by spaces representing the books in that layer.
outputFormat
For each of the ( n ) layers, output a line containing ( k ) integers. These integers represent the books in the layer after rotating to the right by one position. Each number should be separated by a single space.## sample
3 4
1 2 3 4
5 6 7 8
9 10 11 12
4 1 2 3
8 5 6 7
12 9 10 11
</p>