#C6250. Group Elements into Sublists

    ID: 49990 Type: Default 1000ms 256MiB

Group Elements into Sublists

Group Elements into Sublists

You are given a list of elements and a positive integer n. Your task is to group the list elements into continuous sublists where each sublist contains exactly n elements, except possibly the last one which may have fewer elements. Formally, if the list is denoted by L with length m, you need to form sublists such that for each group:

$$L[i:i+n]=[L[i], L[i+1], \cdots, L[i+n-1]]$$

for i = 0, n, 2n, \ldots until the end of the list.

The input will be provided through standard input and the output should be printed to standard output.

inputFormat

The first line contains an integer n indicating the required size of each group.

The second line contains an integer m representing the number of elements in the list.

The third line contains m space-separated elements. These can be either numbers or strings.

outputFormat

Output the grouped elements, one group per line. Each group consists of the elements separated by a single space. There should be no extra spaces at the beginning or end of any line.

## sample
3
9
1 2 3 4 5 6 7 8 9
1 2 3

4 5 6 7 8 9

</p>