#K57072. Dividing Participants into Groups

    ID: 30339 Type: Default 1000ms 256MiB

Dividing Participants into Groups

Dividing Participants into Groups

In this problem, you are given ( T ) test cases. For each test case, the first line contains two integers ( n ) and ( k ), where ( n ) is the total number of participants and ( k ) is the group size. The next line contains ( n ) integers representing the participants' IDs. Your task is to divide the given list into consecutive groups of size ( k ). If the number of participants is not exactly divisible by ( k ), the last group will contain the remaining participants.

Each group should be printed on a separate line in the format: [a b c ..] (with a single space between numbers) and different test cases should be separated by an empty line. Please note that the input and output formats are strictly defined and your program must follow them.

inputFormat

The input begins with a single integer ( T ) denoting the number of test cases. Each test case consists of two lines:
1. The first line contains two integers ( n ) and ( k ), where ( n ) is the number of participants and ( k ) is the number of participants per group.
2. The second line contains ( n ) space-separated integers representing the participants' IDs.

outputFormat

For each test case, output the participants divided into groups. Each group is printed on its own line in the format [a b c ...] with the numbers separated by a single space. After each test case, output an empty line (except after the last test case).## sample

3
6 3
1 2 3 4 5 6
7 2
10 21 13 24 15 36 17
5 5
101 102 103 104 105
[1 2 3]

[4 5 6]

[10 21] [13 24] [15 36] [17]

[101 102 103 104 105]

</p>