Under construction

Still being built. Things may change

A Sad Legend of Sejong and Yeongjae

Interview

Time limit1sMemory limit1024 MB

Summary
Assign each of the N bags to a different day so that every day receives at least its minimum A_i, or report -1 if no assignment exists.
Level

Easy3 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Problem

Sejong lent money to Yeongjae, and he still has not been repaid. Sejong asked for the money many times, but sadly Yeongjae does not seem to understand him. So Sejong gave Yeongjae a final grace period of NN days. Yeongjae must repay all the money he borrowed within these NN days.

Sejong and Yeongjae follow a peculiar rule. On day ii, Sejong gets angry by AiA_i. If Sejong does not receive at least AiA_i won on day ii, he lashes out at Yeongjae. Yeongjae divides his money into NN bags and gives Sejong one bag per day.

Given the minimum amounts Sejong must receive each day and the amounts Yeongjae packed into the bags, write a program that finds a way for Yeongjae to repay the debt without triggering Sejong's anger.

Input

The first line contains NN, the number of days in the grace period. (1≤N≤200 000)(1 \leq N \leq 200\,000)

The second line contains NN positive integers A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N, separated by spaces. AiA_i is the minimum amount Sejong must receive on day ii. (1≤Ai≤108)(1 \leq A_i \leq 10^{8})

The third line contains NN positive integers B1,B2,⋯ ,BNB_1, B_2, \cdots, B_N, separated by spaces. BjB_j is the amount Yeongjae put into bag jj. (1≤Bj≤108)(1 \leq B_j \leq 10^{8})

∑i=1NAi≤2×109\sum_{i=1}^{N} A_i \leq 2 \times 10^{9} and ∑j=1NBj≤2×109\sum_{j=1}^{N} B_j \leq 2 \times 10^{9}.

Output

Print the amount Yeongjae must pay on each day from day 1 to day NN, separated by spaces.

If it is impossible to repay the debt without Sejong becoming angry, print -1 instead.

If several answers are possible, print any one of them.

Examples2

  1. Example 1

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

    Input
    3
    1 3 10000
    9999 9999 9999
    
    Expected output
    -1