#C1235. Close Passageways

    ID: 41767 Type: Default 1000ms 256MiB

Close Passageways

Close Passageways

You are given an integer N representing the number of houses and an integer K representing the number of passageways you must close. The houses are connected sequentially by N - 1 passageways which are numbered from 1 to N - 1. To disconnect all houses from each other, you need to close all passageways. In other words, it is possible to disconnect all houses if and only if

\( K = N - 1 \).

If this condition is met, output the list of passageway numbers to close (i.e. 1, 2, \( \ldots \), N - 1). Otherwise, output -1 indicating that it is impossible to disconnect all houses by closing exactly K passageways.

inputFormat

The input consists of a single line containing two space-separated integers N and K:

  • N: the number of houses (an integer, where N ≥ 1).
  • K: the number of passageways to close.

Note: The houses are connected by exactly N - 1 passageways numbered 1 through N - 1.

outputFormat

If it is possible to disconnect all houses by closing exactly K passageways, output the passageway numbers in increasing order separated by a space on a single line. If it is impossible, output -1.

Example:

  • For input 5 4, since 4 = 5 - 1, output: 1 2 3 4.
  • For input 3 1, since 1 is not equal to 3 - 1, output: -1.
## sample
5 4
1 2 3 4