#C8933. Forming Teams

    ID: 52970 Type: Default 1000ms 256MiB

Forming Teams

Forming Teams

You are given (n) employees with unique integer IDs and an integer (k). Your task is to form all possible teams of exactly (k) employees such that each team is in lexicographical order. In other words, if the employee IDs are sorted as (a_1, a_2, \dots, a_n), then every valid team is a combination ({a_{i_1}, a_{i_2}, \dots, a_{i_k}}) with (i_1 < i_2 < \dots < i_k). For each team, print the (k) employee IDs in increasing order separated by a space. Each team should be printed on a new line.

inputFormat

The input is given via standard input (stdin) and consists of two lines. The first line contains two integers (n) and (k), where (n) is the number of employees and (k) is the team size. The second line contains (n) space-separated integers, the employee IDs.

outputFormat

Output all possible teams (combinations) of exactly (k) employees in lexicographical order. Each team should be printed on a separate line with the employee IDs separated by a space.## sample

4 2
3 1 4 2
1 2

1 3 1 4 2 3 2 4 3 4

</p>