import itertools T = int(input()) # 順列を生成 Permut = list(itertools.permutations([[0, 0], [0, 2], [1, 0], [1, 1], [2, 1], [2, 2]])) for testcase in range(T): A = list(map(int, input().split())) B = list(map(int, input().split())) # 最大値の答え maxv = min(A[0], B[1]) + min(A[1], B[2]) + min(A[2], B[0]) # あいこと負けの最大値 mx_used = 0 # 順列全探索でどの順で使用するかを全探索 for P in Permut: tot = 0 tmp_A = A.copy() tmp_B = B.copy() for u, v in P: d = min(tmp_A[u], tmp_B[v]) tmp_A[u] -= d tmp_B[v] -= d tot += d mx_used = max(mx_used, tot) # 最小値の答え minv = sum(A) - mx_used # 答えを出力 print(minv, maxv)