This page is still under construction.

Parts of this page are still being built. What you see may change.

Snow White and the nn Dwarfs

Time limit2sMemory limit1024 MB

Summary
Order the dwarfs so that at some moment every dwarf is asleep at once; output the order or -1.
Level

Medium6 of 10

Topics
Greedy, Sorting, Implementation, Math
Solved
No attempts yet

Problem

<<They are not dwarfs, they are a punishment!>>, Snow White thought as she tried yet again to put the dwarfs to sleep. You put one to sleep and another has already woken up! And so it goes all night.

Snow White has nn dwarfs, and they are all very different. She knows that putting the ii-th dwarf to sleep takes aia_i minutes, after which he sleeps for exactly bib_i minutes. Help Snow White find out whether she can get at least a minute of rest while all the dwarfs are asleep, and if so, in what order she must put the dwarfs to sleep to achieve it.

For example, suppose there are only two dwarfs, a1=1a_1 = 1, b1=10b_1 = 10, a2=10a_2 = 10, b2=20b_2 = 20. If Snow White starts by putting the first dwarf to sleep, she then needs a whole 10 minutes to put the second one to sleep, and during that time the first one wakes up. But if she starts with the second dwarf, she can then put the first one to sleep in time and get a whole 10 minutes of rest.

Input

The first line contains the number nn (1≤n≤1051\le n\le 10^5). The second line contains the numbers a1,a2,…,ana_1,a_2,\ldots,a_n, and the third line contains the numbers b1,b2,…,bnb_1,b_2,\ldots,b_n (1≤ai,bi≤1091\le a_i, b_i\le 10^9).

Output

Output nn numbers: the order in which the dwarfs must be put to sleep. If Snow White cannot rest, output the number −1-1.

Examples2

  1. Example 1

    Input
    2
    1 10
    10 20
    
    Expected output
    2 1
    
  2. Example 2

    Input
    2
    10 10
    10 10
    
    Expected output
    -1