Alice and Bob have decided to play the game "Rock, Paper, Scissors". 

The game consists of several rounds, each round is independent of each other. In each round, both players show one of the following things at the same time: rock, paper or scissors. If both players showed the same things then the round outcome is a draw. Otherwise, the following rules applied:

  if one player showed rock and the other one showed scissors, then the player who showed rock is considered the winner and the other one is considered the loser;  if one player showed scissors and the other one showed paper, then the player who showed scissors is considered the winner and the other one is considered the loser;  if one player showed paper and the other one showed rock, then the player who showed paper is considered the winner and the other one is considered the loser. 

Alice and Bob decided to play exactly $n$ rounds of the game described above. Alice decided to show rock $a_1$ times, show scissors $a_2$ times and show paper $a_3$ times. Bob decided to show rock $b_1$ times, show scissors $b_2$ times and show paper $b_3$ times. Though, both Alice and Bob did not choose the sequence in which they show things. It is guaranteed that $a_1 + a_2 + a_3 = n$ and $b_1 + b_2 + b_3 = n$.

Your task is to find two numbers:

  the minimum number of round Alice can win;  the maximum number of rounds Alice can win. 


-----Input-----

The first line of the input contains one integer $n$ ($1 \le n \le 10^{9}$) — the number of rounds.

The second line of the input contains three integers $a_1, a_2, a_3$ ($0 \le a_i \le n$) — the number of times Alice will show rock, scissors and paper, respectively. It is guaranteed that $a_1 + a_2 + a_3 = n$.

The third line of the input contains three integers $b_1, b_2, b_3$ ($0 \le b_j \le n$) — the number of times Bob will show rock, scissors and paper, respectively. It is guaranteed that $b_1 + b_2 + b_3 = n$.


-----Output-----

Print two integers: the minimum and the maximum number of rounds Alice can win.


-----Examples-----
Input
2
0 1 1
1 1 0

Output
0 1

Input
15
5 5 5
5 5 5

Output
0 15

Input
3
0 0 3
3 0 0

Output
3 3

Input
686
479 178 29
11 145 530

Output
22 334

Input
319
10 53 256
182 103 34

Output
119 226



-----Note-----

In the first example, Alice will not win any rounds if she shows scissors and then paper and Bob shows rock and then scissors. In the best outcome, Alice will win one round if she shows paper and then scissors, and Bob shows rock and then scissors.

In the second example, Alice will not win any rounds if Bob shows the same things as Alice each round.

In the third example, Alice always shows paper and Bob always shows rock so Alice will win all three rounds anyway.

Difficulty: introductory

Starter code:

Solutions:
import sys
input = sys.stdin.readline

x = int(input())
# 묵 찌 빠
a = list(map(int, input().split()))
b = list(map(int, input().split()))
MAX = min(a[0], b[1])+min(a[1], b[2])+min(a[2], b[0])
MIN = 0
tmp = min(a[0], b[0]+b[2])
a[0] -= tmp
ttmp = min(a[1], b[0]+b[1])
a[1] -= ttmp
tttmp = min(a[2], b[1]+b[2])
a[2] -= tttmp
print(sum(a), MAX)


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
mins=max(0,b[0]-a[0]-a[1],b[1]-a[1]-a[2],b[2]-a[2]-a[0])
maxs=min(a[0],b[1])+min(a[1],b[2])+min(a[2],b[0])
print(mins,maxs)

n = int(input())
a1, a2, a3 = map(int, input().split())
b1, b2, b3 = map(int, input().split())
maxcount = 0
if a1-b2 >0 and b2!=0:
  maxcount+=(b2)
elif b2==0:
  maxcount+=0
else:
  maxcount+=a1
if a2-b3 >0 and b3!=0:
  maxcount+=(b3)
elif b3==0:
  maxcount+=0
else:
  maxcount+=a2
if a3-b1 >0 and b1!=0:
  maxcount+=(b1)
elif b1==0:
  maxcount+=0
else:
  maxcount+=a3
mincount=0
if a1> b1+b3:
  mincount+=(a1-b1-b3)
if a2>b1+b2:
  mincount+=(a2-b1-b2)
if a3>b2+b3:
  mincount+=(a3-b2-b3)
print(mincount, maxcount)

n = int(input())
t1 = list(map(int,input().split()))
t2 = list(map(int,input().split()))
k1 = min(t1[0], t2[1]) + min(t1[1], t2[2]) + min(t1[2], t2[0])
k2 = min(t1[0], n - t2[1]) + min(t1[1], n - t2[2]) + min(t1[2], n - t2[0])
print(n - k2, k1)

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

maxi = min(a[0],b[1])+min(a[1],b[2])+min(a[2],b[0])
minnie = n-(min(a[0],b[0]+b[2])+min(a[1],b[1]+b[0])+min(a[2],b[2]+b[1]))
print(minnie,maxi)

# rock sci paper
import math
for _ in range(1):
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    mi=0
    ar,ass,ap=a[0],a[1],a[2]
    br,bss,bp=b[0],b[1],b[2]
    ar=max(ar-br,0)
    ass=max(ass-bss,0)
    ap=max(ap-bp,0)
    
    rock=min(ar,bp)
    ar-=rock
    bp-=rock
    paper=min(ap,bss)
    ap-=paper
    bss-=paper
    
    sci=min(ass,br)
    ass-=sci
    br-=sci
    mi=ar+ass+ap
    
    ma=0
    ar,ass,ap=a[0],a[1],a[2]
    br,bss,bp=b[0],b[1],b[2]
    rock=min(ar,bss)
    ar-=rock
    bss-=rock
    paper=min(ap,br)
    ap-=paper
    br-=paper
    
    sci=min(ass,bp)
    ass-=sci
    bp-=sci
    ma=rock+paper+sci
    print(mi,ma)
    



from sys import stdin, stdout

def find(A,B,N):
    X=min(A[0],B[1])
    Y=min(A[1],B[2])
    Z=min(A[2],B[0])

    P=min(A[0],B[2]+B[0])
    Q=min(A[1],B[1]+B[0])
    R=min(A[2],B[2]+B[1])
    return N-(P+Q+R), X+Y+Z

def main():
        N=int(stdin.readline())
        A=list(map(int, stdin.readline().split()))
        B=list(map(int, stdin.readline().split()))
        print(" ".join(map(str,find(A,B,N))))
main()

n = int(input())
x1, x2, x3 = list(map(int, input().split()))
y1, y2, y3 = list(map(int, input().split()))
max1, min1 = min(x1, y2)+min(x2, y3)+min(x3, y1), 0
if x1 > y1+y3:
    min1 = x1-y1-y3
elif x2 > y2+y1:
    min1 = x2-y1-y2
elif x3 > y3+y2:
    min1 = x3-y3-y2
print(min1, max1)


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *
import sys
'''
@lru_cache(None)
def fact(x):
    if x<2:
        return 1
    return fact(x-1)*x

@lru_cache(None)
def per(i,j):
    return fact(i)//fact(i-j)

@lru_cache(None)
def com(i,j):
    return per(i,j)//fact(j)

def linc(f,t,l,r):
    while l<r:
        mid=(l+r)//2
        if t>f(mid):
            l=mid+1
        else:
            r=mid
    return l

def rinc(f,t,l,r):
    while l<r:
        mid=(l+r+1)//2
        if t<f(mid):
            r=mid-1
        else:
            l=mid
    return l

def ldec(f,t,l,r):
    while l<r:
        mid=(l+r)//2
        if t<f(mid):
            l=mid+1
        else:
            r=mid
    return l

def rdec(f,t,l,r):
    while l<r:
        mid=(l+r+1)//2
        if t>f(mid):
            r=mid-1
        else:
            l=mid
    return l

def isprime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False
    return True

def power2(n):
    while not n&1:
        n>>=1
    return n==1
'''
'''
for i in range(t):
    #n,m=map(int,input().split())
    n,m=1,0
    graph=defaultdict(set)
    for i in range(m):
        u,v=map(int,input().split())
        graph[u-1].add(v-1)
    visited=[0]*n
    ans=[]
    def delchild(u):
        for child in graph[u]:
            visited[child]=1
            ans.append(child+1)
    for i in range(n):
        if not visited[i]:
            children=graph[i]
            if len(children)==1:
                u=children.pop()
                visited[u]=1
                delchild(u)
            elif len(children)==2:
                u=children.pop()
                v=children.pop()
                if u in graph[v]:
                    delchild(v)
                    visited[v]=1
                elif v in graph[u]:
                    delchild(u)
                    visited[u]=1
                else:
                    delchild(u)
                    delchild(v)
                    visited[u]=visited[v]=1
    print(len(ans))
    sys.stdout.flush()
    print(' '.join(map(str,ans)))
    sys.stdout.flush()

import time
s=time.time()
e=time.time()
print(e-s)
'''
'''
t=int(input())
for i in range(t):
    #n,m=map(int,input().split())
    n=int(input())
    x=int(sqrt(n))
    if x*x==n:
        ans=2*x-2
    elif x*(x+1)>=n:
        ans=2*x-1
    else:
        ans=2*x
    print(ans)
'''
n=int(input())
a1,a2,a3=list(map(int,input().split()))
b1,b2,b3=list(map(int,input().split()))
ma=min(a1,b2)+min(a2,b3)+min(a3,b1)
mi=max(0,a1-b1-b3)+max(0,a2-b1-b2)+max(0,a3-b2-b3)
print(mi,ma)
  
    




# rock, scissors, paper
def count_wins(a1, a2, a3, b1, b2, b3):
    return min(a1, b2) + min(a2, b3) + min(a3, b1)


def solve_e(a1, a2, a3, b1, b2, b3):
    wins = count_wins(a1, a2, a3, b1, b2, b3)
    loses = max(0, a1 - b1 - b3) + max(0, a2 - b2 - b1) + max(0, a3 - b2 - b3)
    return loses, wins

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
print(*solve_e(*a, *b))


n=int(input())
a1,a3,a2=map(int,input().split())
b1,b3,b2=map(int,input().split())
maxx=min(a1,b3)+min(a2,b1)+min(a3,b2)
minn=max(0,a1-b1-b2)+max(0,a2-b2-b3)+max(0,a3-b3-b1)
print(minn,maxx)

import sys
input = sys.stdin.readline

n=int(input())
a1,a2,a3=list(map(int,input().split()))
b1,b2,b3=list(map(int,input().split()))

V=8

EDGE=[[0]*V for i in range(V)]

start=0
goal=V-1

EDGE[0][1]=a1
EDGE[0][2]=a2
EDGE[0][3]=a3

EDGE[4][7]=b1
EDGE[5][7]=b2
EDGE[6][7]=b3

EDGE[1][4]=float("inf")
EDGE[1][6]=float("inf")

EDGE[2][4]=float("inf")
EDGE[2][5]=float("inf")

EDGE[3][5]=float("inf")
EDGE[3][6]=float("inf")

ANS=0
while True:
    USED=[0]*V
    ROUTE=[-1]*V
    Q=[(start,float("inf"))]
    
    while Q: # DFS
        NOW,cost=Q.pop()
        if NOW==goal:
            break

        for to in range(V):
            if USED[to]==0 and EDGE[NOW][to]!=0: 
                ROUTE[to]=NOW
                USED[to]=1
                Q.append((to,min(cost,EDGE[NOW][to])))
    else:
        break
    
    ANS+=cost
    i=goal
    while i!=start:
        j=ROUTE[i]
        EDGE[j][i]-=cost
        EDGE[i][j]+=cost
        i=j
       
print(n-ANS,min(a1,b2)+min(a2,b3)+min(a3,b1))



import sys
readline = sys.stdin.readline

from heapq import heappop as hpp, heappush as hp
class MinCostFlowwithDijkstra:
    INF = 1<<60
    
    def __init__(self, N):
        self.N = N
        self.Edge = [[] for _ in range(N)]
    
    def add_edge(self, st, en, cap, cost):
        self.Edge[st].append([en, cap, cost, len(self.Edge[en])])
        self.Edge[en].append([st, 0, -cost, len(self.Edge[st])-1])
    
    def get_mf(self, so, si, fl):
        N = self.N
        INF = self.INF
        res = 0
        Pot = [0]*N
        geta = N
        
        
        prv = [None]*N
        prenum = [None]*N
        while fl:
            dist = [INF]*N
            dist[so] = 0
            Q = [so]
            
            while Q:
                cost, vn = divmod(hpp(Q), geta)
                if dist[vn] < cost:
                    continue
                
                for enum in range(len(self.Edge[vn])):
                    vf, cap, cost, _ = self.Edge[vn][enum]
                    cc = dist[vn] + cost - Pot[vn] + Pot[vf]
                    if cap > 0 and dist[vf] > cc:
                        dist[vf] = cc
                        prv[vf] = vn
                        prenum[vf] = enum
                        hp(Q, cc*geta + vf)
            
            if dist[si] == INF:
                return -1
            
            for i in range(N):
                Pot[i] -= dist[i]
            
            cfl = fl
            vf = si
            while vf != so:
                cfl = min(cfl, self.Edge[prv[vf]][prenum[vf]][1])
                vf = prv[vf]
            
            fl -= cfl
            res -= cfl*Pot[si]
            vf = si
            while vf != so:
                e = self.Edge[prv[vf]][prenum[vf]]
                e[1] -= cfl
                self.Edge[vf][e[3]][1] += cfl
                vf = prv[vf]
        return res


N = int(readline())
ra, sa, pa = map(int, readline().split())
rb, sb, pb = map(int, readline().split())

maxwin = min(ra, sb) + min(sa, pb) + min(pa, rb)
 

D = MinCostFlowwithDijkstra(8)
D.add_edge(0, 1, ra, 0)
D.add_edge(0, 2, sa, 0)
D.add_edge(0, 3, pa, 0)
D.add_edge(4, 7, rb, 0)
D.add_edge(5, 7, sb, 0)
D.add_edge(6, 7, pb, 0)

D.add_edge(1, 4, N, 0)
D.add_edge(1, 5, N, 1)
D.add_edge(1, 6, N, 0)
D.add_edge(2, 4, N, 0)
D.add_edge(2, 5, N, 0)
D.add_edge(2, 6, N, 1)
D.add_edge(3, 4, N, 1)
D.add_edge(3, 5, N, 0)
D.add_edge(3, 6, N, 0)

print(D.get_mf(0, 7, N), maxwin)

import heapq

class mcf_graph_int_cost:

    def __init__(self, n):
        self.n = n
        self.pos = []
        self.g = [[] for _ in range(n)]


    def add_edge(self, from_, to, cap, cost):
        # assert 0 <= from_ < self.n
        # assert 0 <= to < self.n
        m = len(self.pos)
        self.pos.append((from_, len(self.g[from_])))
        self.g[from_].append(self.__class__._edge(to, len(self.g[to]), cap, cost))
        self.g[to].append(self.__class__._edge(from_, len(self.g[from_]) - 1, 0, -cost))
        return m


    class edge:
        def __init__(self, from_, to, cap, flow, cost):
            self.from_ = from_
            self.to = to
            self.cap = cap
            self.flow = flow
            self.cost = cost


    def get_edge(self, i):
        _e = self.g[self.pos[i][0]][self.pos[i][1]]
        _re = self.g[_e.to][_e.rev]
        return self.__class__.edge(self.pos[i][0], _e.to, _e.cap + _re.cap, _re.cap, _e.cost)


    def edges(self):
        ret = []
        for i in range(len(self.pos)):
            _e = self.g[self.pos[i][0]][self.pos[i][1]]
            _re = self.g[_e.to][_e.rev]
            ret.append(self.__class__.edge(self.pos[i][0], _e.to, _e.cap + _re.cap, _re.cap, _e.cost))
        return ret


    def _dual_ref(self, s, t):
        self.dist = [4294967295] * self.n
        self.pv = [-1] * self.n
        self.pe = [-1] * self.n
        self.vis = [False] * self.n

        que = [s] # s ==  (0 << 32) + s 
        self.dist[s] = 0
        while que:
            v = heapq.heappop(que) & 4294967295
            if self.vis[v]:
                continue
            self.vis[v] = True
            if v == t:
                break
            for i in range(len(self.g[v])):
                e = self.g[v][i]
                if self.vis[e.to] or e.cap == 0:
                    continue
                cost = e.cost - self.dual[e.to] + self.dual[v]
                if self.dist[e.to] > self.dist[v] + cost:
                    self.dist[e.to] = self.dist[v] + cost
                    self.pv[e.to] = v
                    self.pe[e.to] = i
                    heapq.heappush(que, ((self.dist[e.to] << 32) + e.to))
        if not self.vis[t]:
            return False

        for v in range(self.n):
            if not self.vis[v]:
                continue
            self.dual[v] -= self.dist[t] - self.dist[v]
        
        return True


    def slope(self, s, t, flow_limit=4294967295):
        # assert 0 <= s < self.n
        # assert 0 <= t < self.n
        # assert s != t
        
        self.dual = [0] * self.n
        self.dist = [4294967295] * self.n
        self.pv = [-1] * self.n
        self.pe = [-1] * self.n
        self.vis = [False] * self.n
        
        flow = 0
        cost = 0
        prev_cost = -1
        result = [(flow, cost)]
        while flow < flow_limit:
            if not self._dual_ref(s, t):
                break
            c = flow_limit - flow
            v = t
            while v != s:
                c = min(c, self.g[self.pv[v]][self.pe[v]].cap)
                v = self.pv[v]
            v = t
            while v != s:
                e = self.g[self.pv[v]][self.pe[v]]
                e.cap -= c
                self.g[v][e.rev].cap += c
                v = self.pv[v]
            d = -self.dual[s]
            flow += c
            cost += c * d
            if prev_cost == d:
                result.pop()
            result.append((flow, cost))
            prev_cost = cost
        return result


    def flow(self, s, t, flow_limit=4294967295):
        return self.slope(s, t, flow_limit)[-1]

    
    class _edge:
        def __init__(self, to, rev, cap, cost):
            self.to = to
            self.rev = rev
            self.cap = cap
            self.cost = cost

INF = 10 ** 9

n = int(input())
a1, a2, a3 = list(map(int, input().split()))
b1, b2, b3 = list(map(int, input().split()))

g = mcf_graph_int_cost(8)
g.add_edge(0, 1, a1, 0)
g.add_edge(0, 2, a2, 0)
g.add_edge(0, 3, a3, 0)
g.add_edge(4, 7, b1, 0)
g.add_edge(5, 7, b2, 0)
g.add_edge(6, 7, b3, 0)
for i in range(1, 4):
    for j in range(4, 7):
        cost = 1 if (j - i) % 3 == 1 else 0
        g.add_edge(i, j, INF, cost)

f, ans1 = g.flow(0, 7)

ans2 = min(a1, b2) + min(a2, b3) + min(a3, b1)
print(ans1, ans2)



# Dinic's algorithm
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**18
        G = self.G
        while self.bfs(s, t):
            *self.it, = list(map(iter, self.G))
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow
N, = list(map(int, input().split()))
a, b, c = list(map(int, input().split()))
x, y, z = list(map(int, input().split()))
#print(min(a, y)+min(b, z)+min(c, x))
INF = 10**9
dnc = Dinic(8)
dnc.add_edge(0, 1, a)
dnc.add_edge(0, 2, b)
dnc.add_edge(0, 3, c)
dnc.add_edge(1, 4, INF)
dnc.add_edge(2, 5, INF)
dnc.add_edge(3, 6, INF)
dnc.add_edge(1, 6, INF)
dnc.add_edge(2, 4, INF)
dnc.add_edge(3, 5, INF)

dnc.add_edge(4, 7, x)
dnc.add_edge(5, 7, y)
dnc.add_edge(6, 7, z)
print(N-dnc.flow(0, 7), min(a, y)+min(b, z)+min(c, x))


n,arr1,arr2=int(input()),[int(i) for i in input().split()],[int(i) for i in input().split()]
ma=0
a,b=[],[]
for i in range (10):
    a.append(arr1)
    b.append(arr2)
ma+=min([arr1[0],arr2[1]])
ma+=min([arr1[1],arr2[2]])
ma+=min([arr1[2],arr2[0]])
mi=n+1
#print(a,b)
for x in range(2):
    for y in range(2):
        for z in range(2):
            aa,bb=a[x*4+y*2+z],b[x*4+y*2+z]
            #print(aa,bb,arr1,arr2,a[x*4+y*2+z],b[x*4+y*2+z])
            xx,yy,zz=min([aa[0],bb[0]]),min([aa[1],bb[1]]),min([aa[2],bb[2]])
            m=[0]*(10)
            if(x==0):
                m[0]-=xx
                m[3]-=xx
            if(y==0):
                m[1]-=yy
                m[4]-=yy
            if(z==0):
                m[2]-=zz
                m[5]-=zz
            xx,yy,zz=min([aa[0]+m[0],bb[2]+m[5]]),min([aa[1]+m[1],bb[0]+m[3]]),min([aa[2]+m[2],bb[1]+m[4]])
            m[0]-=xx
            m[1]-=yy
            m[2]-=zz
            m[3]-=yy
            m[4]-=zz
            m[5]-=xx
            t=0
            xx,yy,zz=min([aa[0]+m[0],bb[0]+m[3]]),min([aa[1]+m[1],bb[1]+m[4]]),min([aa[2]+m[2],bb[2]+m[5]])
            m[0]-=xx
            m[3]-=xx
            m[1]-=yy
            m[4]-=yy
            m[2]-=zz
            m[5]-=zz
            t+=min([aa[0]+m[0],bb[1]+m[4]])
            t+=min([aa[1]+m[1],bb[2]+m[5]])
            t+=min([aa[2]+m[2],bb[0]+m[3]])
            mi=min([mi,t])
            #print(x,y,z,t)
print(mi,ma)

from sys import stdin

tt = 1

for loop in range(tt):

    n = int(stdin.readline())
    a = list(map(int,stdin.readline().split()))
    b = list(map(int,stdin.readline().split()))

    maxans = 0
    for i in range(3):
        maxans += min(a[i],b[(i+1) % 3])

    b = [b[1],b[2],b[0]]
    minans = 0
    
    for i in range(3):
        now = a[i]
        for j in range(3):
            if i != j:
                now -= b[j]
        minans = max(minans , now)

    for i in range(3):
        now = b[i]
        for j in range(3):
            if i != j:
                now -= a[j]
        minans = max(minans , now)

    print(minans , maxans)

    


n = int(input())
a1,a2,a3 = list(map(int,input().split()))
b1,b2,b3 = list(map(int,input().split()))
maxx = min(b2,a1)+min(a2,b3)+min(a3,b1)
c = 0
if b1>a1:
	c += 1
if b2>a2:
	c += 1
if b3>a3:
	c += 1

if c==1:
	if b1>a1:
		minn = max(0,min(b1,a3-(b2+b3)))
	elif b2>a2:
		minn = max(0,min(b2,a1-(b1+b3)))
	else:
		minn = max(0,min(b3,a2-(b1+b2)))
else:
	if a1>b1:
		minn = max(0,min(b2,a1-(b1+b3)))
	elif a2>b2:
		minn = max(0,min(b3,a2-(b1+b2)))
	else:
		minn = max(0,min(b1,a3-(b3+b2)))

print(minn,maxx)


n = int(input())

a1, a2, a3 = list(map(int, input().split()))
b1, b2, b3 = list(map(int, input().split()))

min_wins = n - (min(a1, n-b2) + min(a2, n-b3) + min(a3, n-b1))
max_wins = min(a1, b2) + min(a2, b3) + min(a3, b1)

print(min_wins, max_wins)


from heapq import heappush, heappop
class MinCostFlow:
    INF = 10**18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        forward = [to, cap, cost, None]
        backward = forward[3] = [fr, 0, -cost, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def flow(self, s, t, f):
        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0]*N
        prv_v = [0]*N
        prv_e = [None]*N

        d0 = [INF]*N
        dist = [INF]*N

        while f:
            dist[:] = d0
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                r0 = dist[v] + H[v]
                for e in G[v]:
                    w, cap, cost, _ = e
                    if cap > 0 and r0 + cost - H[w] < dist[w]:
                        dist[w] = r = r0 + cost - H[w]
                        prv_v[w] = v; prv_e[w] = e
                        heappush(que, (r, w))
            if dist[t] == INF:
                return None

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, prv_e[v][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = prv_e[v]
                e[1] -= d
                e[3][1] += d
                v = prv_v[v]
        return res

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

d = MinCostFlow(8)

d.add_edge(0,1,a[0],0)
d.add_edge(0,2,a[1],0)
d.add_edge(0,3,a[2],0)

d.add_edge(1,4,n,0)
d.add_edge(1,5,n,1)
d.add_edge(1,6,n,0)

d.add_edge(2,4,n,0)
d.add_edge(2,5,n,0)
d.add_edge(2,6,n,1)

d.add_edge(3,4,n,1)
d.add_edge(3,5,n,0)
d.add_edge(3,6,n,0)

d.add_edge(4,7,b[0],0)
d.add_edge(5,7,b[1],0)
d.add_edge(6,7,b[2],0)


M = min(a[0],b[1]) + min(a[1],b[2] )+ min(a[2],b[0])

print(d.flow(0,7,n),M)

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

max_ = 0
max_ += min(A[0], B[1])
max_ += min(A[1], B[2])
max_ += min(A[2], B[0])


min_ =0
min_ += max(0, A[0]-B[0]-B[2])
min_ += max(0, A[1]-B[0]-B[1])
min_ += max(0, A[2]-B[1]-B[2])

print(min_, max_)


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
maxx,minn=0,0
if a[0]>b[1]:
    maxx+=(a[0]-b[1])
if a[1]>b[2]:
    maxx+=(a[1]-b[2])
if a[2]>b[0]:
    maxx+=(a[2]-b[0])
if a[0]>b[0]+b[2]:
    minn+=(a[0]-b[0]-b[2])
if a[1]>b[1]+b[0]:
    minn+=(a[1]-b[1]-b[0])
if a[2]>b[1]+b[2]:
    minn+=(a[2]-b[1]-b[2])
print(minn,n-maxx)

import itertools
n=int(input())
a1,a2,a3=map(int,input().split())
b1,b2,b3=map(int,input().split())
win=min(a1,b2)+min(a2,b3)+min(a3,b1)
mx=0
pt=-1
mx=0
for lists in itertools.permutations(range(6)):
    ct=0
    aa1=a1
    aa2=a2
    aa3=a3
    bb1=b1
    bb2=b2
    bb3=b3
    for pt in lists:
        L=[min(aa1,bb1),min(aa1,bb3),min(aa2,bb1),min(aa2,bb2),min(aa3,bb2),min(aa3,bb3)]
        if pt==0:
            aa1-=L[0]
            bb1-=L[0]
        if pt==1:
            aa1-=L[1]
            bb3-=L[1]
        if pt==2:
            aa2-=L[2]
            bb1-=L[2]
        if pt==3:
            aa2-=L[3]
            bb2-=L[3]
        if pt==4:
            aa3-=L[4]
            bb2-=L[4]
        if pt==5:
            aa3-=L[5]
            bb3-=L[5]
        ct+=L[pt]
    if ct>mx:
        mx=ct
print(n-mx,win)

a=int(input())
d,r,l=map(int,input().split(" "))
z,j,k=map(int,input().split(" "))
maxx=min(l,z)+min(d,j)+min(r,k)
minn=max(0,l-(j+k))+max(0,d-(z+k))+max(0,r-(z+j))
print(minn,maxx)

n=int(input())
a1,a2,a3=map(int,input().split())
b1,b2,b3=map(int,input().split())
c1=a1-(b3+b1)
c2=a2-(b1+b2)
c3=a3-(b2+b3)
s=0
if(c1>0):
    s+=c1
if(c2>0):
    s+=c2
if(c3>0):
    s+=c3

    
print(s,end=" ")
print(min(a1,b2)+min(a2,b3)+min(a3,b1))

    

import sys

    
def main():
    #n = iinput()
    #k = iinput() 
    #m = iinput() 
    n = int(sys.stdin.readline().strip()) 
    #n, k = rinput()
    #n, m = rinput()
    #m, k = rinput()
    #n, k, m = rinput()
    #n, m, k = rinput()
    #k, n, m = rinput()
    #k, m, n = rinput() 
    #m, k, n = rinput()
    #m, n, k = rinput()
    #n, t = map(int, sys.stdin.readline().split())
    #q = list(map(int, sys.stdin.readline().split()))
    #q = linput()
    a,a1,a2= list(map(int, sys.stdin.readline().split()))
    b,b1,b2= list(map(int, sys.stdin.readline().split()))
    res = min(a, b1) + min(a1, b2) + min(a2, b)
    if b >= a1 + a:
        ans = a2 - (n - b)
    elif b1 >= a1 + a2:
        ans = a - (n - b1)   
    elif b2 >= a2 + a:
        ans = a1 - (n - b2) 
    elif (b == a and b1 == a1 and b2 == a2):
        ans = 0
    elif a > b and a1 > b1:
        b2 -= a2
        a -= b2
        a1 -= b1
        if a <= 0:
            ans = a1 - b
        else:
            ans = a + a1 - b
    elif a2 > b2 and a1 > b1:
        b -= a
        a1 -= b
        a2 -= b2
        if a1 <= 0:
            ans = a2 - b1
        else:
            ans = a2 + a1 - b1
    elif a > b and a2 > b2:
        b1 -= a1
        a2 -= b1
        a -= b
        if a2 <= 0:
            ans = a - b
        else:
            ans = a2 + a - b  
    elif a > b:
        a -= b
        b1 -= a1
        a2 -= b1
        a1 = 0
        ans = a + a2 - b2
    elif a1 > b1:
        a1 -= b1
        b2 -= a2
        a -= b2
        a2 = 0
        ans = a + a1 - b
    elif a2 > b2:
        a2 -= b2
        b -= a
        a1 -= b
        a = 0
        ans = a2 + a1 - b1   
    print(max(0, ans), res)
        
        
        
    
           
        
            
    
    
    
    
    
    
            
                
        
    
            
        

            
        
    
                
    
    
    
            
    
        
    

for i in range(1):
    main()
    


import sys
input=sys.stdin.readline

def fa(a1,b2,a2,b3,a3,b1):
    c=0
    bv=max(b1-a1-a2,0)
    c=c+bv
    
    a2=a2-b1
    if (a2<0):
        a1=max(a1+a2,0)
        a2=0

    #print(a1,a2,a3)
    bv=max(b2-a2-a3,0)
    c=c+bv
    a2=a2-b2
    if (a2<0):
        a3=max(a2+a3,0)


    #print(a1,a2,a3)
    bv=max(b3-a1-a3,0)
    c=c+bv
    
    return c
    
def main():
    n=int(input())
    a1,a2,a3=list(map(int,input().split()))
    b1,b2,b3=list(map(int,input().split()))

    v=min(a1,b2)+min(a2,b3)+min(a3,b1)

    c=min(fa(a1,b2,a2,b3,a3,b1),fa(a1,b2,a3,b1,a2,b3),fa(a2,b3,a1,b2,a3,b1),fa(a2,b3,a3,b1,a1,b2),fa(a3,b1,a1,b2,a2,b3),fa(a3,b1,a2,b3,a1,b2))
        
    print(c,v)
main()


from itertools import permutations


def read_int():
    return int(input())


def read_ints():
    return list(map(int, input().split(' ')))


n = read_int()
a = list(read_ints())
b = list(read_ints())
hi = min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0])
lo = n
prs = [(0, 0), (0, 1), (1, 1), (1, 2), (2, 2), (2, 0)]
for seq in permutations(prs):
    a1 = a.copy()
    b1 = b.copy()
    no_win = 0
    for pr in seq:
        ai = pr[1]
        bi = pr[0]
        delta = min(a1[ai], b1[bi])
        no_win += delta
        a1[ai] -= delta
        b1[bi] -= delta
    lo = min(lo, n - no_win)
print(lo, hi)


import sys,math
from collections import Counter,deque,defaultdict
from bisect import bisect_left,bisect_right 
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = inpl()
sua = sum(a)
sub = sum(b)
mi_res = 0
if a[0] > b[0]+b[2]: mi_res = a[0]-b[0]-b[2]
if a[1] > b[0]+b[1]: mi_res = a[1]-b[0]-b[1]
if a[2] > b[2]+b[1]: mi_res = a[2]-b[2]-b[1]

ma_res = min(a[0],b[1]) + min(a[1],b[2]) + min(a[2],b[0])
print(mi_res,ma_res)

def findWins(n,a,b):
    maxAliceWins = min(a[0],b[1]) + min(a[1],b[2]) + min(a[2],b[0])
    minAliceWins = max(0, b[0]-a[0]-a[1]) + max(0, b[1]-a[1]-a[2]) + max(0, b[2]-a[2]-a[0])
    

    print(minAliceWins,maxAliceWins)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
findWins(n,a,b)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
acopy=a.copy()
bcopy=b.copy()
ans=[]
p=0
for i in range(3):
    p=max(p,a[i]-b[i]-b[i-1])
ans.append(str(p))
acopy=a.copy()
bcopy=b.copy()
p=0
for i in range(3):
    t=min(acopy[i-1],bcopy[i])
    p+=t
ans.append(str(p))
print(' '.join(ans))

import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter

#sys.setrecursionlimit(100000000)

inp = lambda: int(input())
strng = lambda: input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda: list(input().strip())
mul = lambda: list(map(int, input().strip().split()))
mulf = lambda: list(map(float, input().strip().split()))
seq = lambda: list(map(int, input().strip().split()))

ceil = lambda x: int(x) if (x == int(x)) else int(x) + 1
ceildiv = lambda x, d: x // d if (x % d == 0) else x // d + 1

flush = lambda: stdout.flush()
stdstr = lambda: stdin.readline()
stdint = lambda: int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda: list(map(int, stdstr().split()))

mod = 1000000007

n = stdint()

a1,a2,a3 = stdarr()
b1,b2,b3 = stdarr()

mi = 0
ma = 0

#for max
wi = min(a1, b2)
re = max(a1-wi, 0)
draw = min(re, b1)
re = re-draw
lose = min(re, b3)

ma += wi

wi = min(a2, b3)
re = max(a2-wi, 0)
draw = min(re, b2)
re = re-draw
lose = min(re, b1)

ma += wi

wi = min(a3, b1)
re = max(a3-wi, 0)
draw = min(re, b3)
re = re-draw
lose = min(re, b2)

ma += wi

#for min

l1 = min(a1, b3)
re = max(a1-l1, 0)
draw = min(re, b1)
wi = min(re-draw, b2)


mi += wi

l1 = min(a2, b1)
re = max(a2-l1, 0)
draw = min(re, b2)
wi = min(re-draw, b3)

mi += wi

l1 = min(a3, b2)
re = max(a3-l1, 0)
draw = min(re, b3)
wi = min(re-draw, b1)

mi += wi

print(mi, ma)


from itertools import permutations

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a_r, a_s, a_p = a
b_r, b_s, b_p = b
a_max_win = 0
k = min(a_r, b_s)
a_max_win += k
a_r -= k
b_s -= k
k = min(a_s, b_p)
a_max_win += k
a_s -= k
b_p -= k
k = min(a_p, b_r)
a_max_win += k
a_p -= k
b_r -= k

a_r, a_s, a_p = b
b_r, b_s, b_p = a


def simulate(a__r, a__s, a__p, b__r, b__s, b__p, order):
    for i in order:
        if i == 0:
            k = min(a__r, b__s)
            a__r -= k
            b__s -= k
        elif i == 1:
            k = min(a__s, b__p)
            a__s -= k
            b__p -= k
        elif i == 2:
            k = min(a__p, b__r)
            a__p -= k
            b__r -= k
        elif i == 3:
            k = min(a__r, b__r)
            a__r -= k
            b__r -= k
        elif i == 4:
            k = min(a__s, b__s)
            a__s -= k
            b__s -= k
        else:
            k = min(a__p, b__p)
            a__p -= k
            b__p -= k
    return sum([a__r, a__s, a__p])


print(min(simulate(a_r, a_s, a_p, b_r, b_s, b_p, p) for p in permutations(list(range(6)))), a_max_win)