/* from itertools import permutations T = int(input()) def get_min(a,b): ok = [(0,2),(1,0),(2,1),(0,0),(1,1),(2,2)] ret = 10**9 for oks in permutations(ok): now_a = a[:];now_b = b[:] for c,d in oks: v = min(now_a[c],now_b[d]) now_a[c] -= v;now_b[d] -= v ret = min(ret,sum(now_a)) return ret for _ in range(T): 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 = get_min(A,B) print(MIN,MAX) */ #include using namespace std; const int INF = 1e9; int get_min(vector a, vector b) { vector> ok = {{0, 2}, {1, 0}, {2, 1}, {0, 0}, {1, 1}, {2, 2}}; int ret = INF; do { vector now_a = a, now_b = b; for (auto [c, d] : ok) { int v = min(now_a[c], now_b[d]); now_a[c] -= v; now_b[d] -= v; } ret = min(ret, accumulate(now_a.begin(), now_a.end(), 0)); } while (next_permutation(ok.begin(), ok.end())); return ret; } int main() { int T; cin >> T; while (T--) { vector A(3), B(3); for (int i = 0; i < 3; i++) cin >> A[i]; for (int i = 0; i < 3; i++) cin >> B[i]; int MAX = 0; MAX += min(A[0], B[1]); MAX += min(A[1], B[2]); MAX += min(A[2], B[0]); int MIN = get_min(A, B); cout << MIN << " " << MAX << endl; } return 0; }