#C7511. Daily Menu Rotation
Daily Menu Rotation
Daily Menu Rotation
You are given a list of menu items and you need to generate a daily menu for M days. On the 1st day, the menu appears in its original order. On each subsequent day, the menu is rotated cyclically to the left by one item. More formally, for the i-th day (starting from i=1), the shift is given by (shift = (i-1) \mod N), where N is the number of menu items.
For example, if (N=4), items are [Pasta, Burger, Salad, Fries] and (M=3), then the menus for the three days will be:
Day 1: Pasta Burger Salad Fries
Day 2: Burger Salad Fries Pasta
Day 3: Salad Fries Pasta Burger
inputFormat
The input is read from standard input (stdin) and has the following format:
Line 1: Two integers (N) and (M), where (N) is the number of menu items and (M) is the number of days.
Line 2: (N) strings separated by spaces representing the menu items.
outputFormat
Print (M) lines to standard output (stdout). Each line corresponds to the menu for that day. The menu for the i-th day is formed by cyclically shifting the original list to the left by (i-1) positions. The items on each line should be printed in order and separated by a single space.## sample
4 3
Pasta Burger Salad Fries
Pasta Burger Salad Fries
Burger Salad Fries Pasta
Salad Fries Pasta Burger
</p>