Under construction

Still being built. Things may change

Thinking Heap

Time limit1sMemory limit512 MB

Summary
Given N, k, and p, the task is to find an insertion order of 1 to N into an empty binary min-heap that places k at array index p, or print -1 if none exists.
Level

Medium6 of 10

Topics
Tree, Greedy, Array
Solved
No attempts yet

Problem

A binary heap is one way to implement a heap, and it is built as a complete binary tree. A complete binary tree is a kind of binary tree in which every level except the last is full, and the nodes on the last level are packed to the left.


<그림> Example of a complete binary tree

A complete binary tree is easy to implement with a one-dimensional array. Number each node as shown below and use that number as the index into the array.


<그림> Complete binary tree with numbered nodes

With this layout, the insertion algorithm for a binary min-heap is simple to implement. The code below implements the insertion algorithm in C++. Small issues in the code are ignored. Calling the insert_heap() function inserts an element into the binary min-heap correctly.


<그림> Code implementing the algorithm that inserts an element into a binary min-heap

Start with an empty binary min-heap. Insert NN distinct natural numbers from 1 to NN inclusive, one at a time with the insert_heap() function. After all NN numbers are inserted, find an insertion order that places the number kk at position pp of the heap array. Count the first cell of the array as position 0.

Input

The first line contains a natural number NN (1≤N≤200,0001 \le N \le 200,000). The second line contains two natural numbers kk and pp (1≤k,p≤N1 \le k, p \le N), separated by a space.

Output

If an insertion order exists that places kk at position pp of the heap array, print the number to insert on each line, with the ii-th line holding the ii-th number to insert. If several orders are possible, print any one of them. If no such order exists, print -1 on the first line.

Examples2

  1. Example 1

    Input
    5
    3 5
    
    Expected output
    5
    2
    4
    1
    3
    
  2. Example 2

    Input
    6
    2 4
    
    Expected output
    -1