Soon a school Olympiad in Informatics will be held in Berland, *n* schoolchildren will participate there.

At a meeting of the jury of the Olympiad it was decided that each of the *n* participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student will receive exactly one diploma.

They also decided that there must be given at least *min*<sub class="lower-index">1</sub> and at most *max*<sub class="lower-index">1</sub> diplomas of the first degree, at least *min*<sub class="lower-index">2</sub> and at most *max*<sub class="lower-index">2</sub> diplomas of the second degree, and at least *min*<sub class="lower-index">3</sub> and at most *max*<sub class="lower-index">3</sub> diplomas of the third degree.

After some discussion it was decided to choose from all the options of distributing diplomas satisfying these limitations the one that maximizes the number of participants who receive diplomas of the first degree. Of all these options they select the one which maximizes the number of the participants who receive diplomas of the second degree. If there are multiple of these options, they select the option that maximizes the number of diplomas of the third degree.

Choosing the best option of distributing certificates was entrusted to Ilya, one of the best programmers of Berland. However, he found more important things to do, so it is your task now to choose the best option of distributing of diplomas, based on the described limitations.

It is guaranteed that the described limitations are such that there is a way to choose such an option of distributing diplomas that all *n* participants of the Olympiad will receive a diploma of some degree.
The first line of the input contains a single integer *n* (3 ≤ *n* ≤ 3·10<sup class="upper-index">6</sup>) — the number of schoolchildren who will participate in the Olympiad.

The next line of the input contains two integers *min*<sub class="lower-index">1</sub> and *max*<sub class="lower-index">1</sub> (1 ≤ *min*<sub class="lower-index">1</sub> ≤ *max*<sub class="lower-index">1</sub> ≤ 10<sup class="upper-index">6</sup>) — the minimum and maximum limits on the number of diplomas of the first degree that can be distributed.

The third line of the input contains two integers *min*<sub class="lower-index">2</sub> and *max*<sub class="lower-index">2</sub> (1 ≤ *min*<sub class="lower-index">2</sub> ≤ *max*<sub class="lower-index">2</sub> ≤ 10<sup class="upper-index">6</sup>) — the minimum and maximum limits on the number of diplomas of the second degree that can be distributed. 

The next line of the input contains two integers *min*<sub class="lower-index">3</sub> and *max*<sub class="lower-index">3</sub> (1 ≤ *min*<sub class="lower-index">3</sub> ≤ *max*<sub class="lower-index">3</sub> ≤ 10<sup class="upper-index">6</sup>) — the minimum and maximum limits on the number of diplomas of the third degree that can be distributed. 

It is guaranteed that *min*<sub class="lower-index">1</sub> + *min*<sub class="lower-index">2</sub> + *min*<sub class="lower-index">3</sub> ≤ *n* ≤ *max*<sub class="lower-index">1</sub> + *max*<sub class="lower-index">2</sub> + *max*<sub class="lower-index">3</sub>.
n=int(input())
mn=[]
mx=[]
ans=[]
for i in range(1,4):
    x,y=map(int,(input().split()))
    mn.append(x)
    mx.append(y)
m1=n-(mn[1]+mn[2])
if m1<mx[0]:
   ans.append(m1)
else:
    ans.append(mx[0])
n-=ans[0]
m2=n-mn[2]
if m2<mx[1]:
    ans.append(m2)
else:
    ans.append(mx[1])
ans.append(n-ans[1])
for i in range(len(ans)):
    print(ans[i],end=' ')

