#include using namespace std; using i32 = int; using i64 = long long; using f64 = long double; using i128 = __int128_t; using p2 = pair; using el = tuple; // using mint = atcoder::modint998244353; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } i64 pow(i64 x, i64 n) { i64 res = 1; i64 t = x; while (n > 0) { if (n & 1) { res = res * t; } t = t * t; } return res; } void _main() { i64 t; cin >> t; for (;t--;) { vector a(3), b(3); for (i64 i = 0; i < 3; i++) cin >> a[i]; for (i64 i = 0; i < 3; i++) cin >> b[i]; i64 mx = 0, mn = 1e18; for (i64 i = 0; i < 3; i++) { mx += min(a[i], b[(i + 1) % 3]); } for (i64 i = 0; i < 3; i++) { for (i64 j = 0; j < 3; j++) { i64 ci = i, cj = j; i64 x = 0, y = 0; i64 cnt = 0; while (ci < i + 3 || cj < j + 3) { if (x == y) { if ((ci + 1) % 3 == cj % 3) { cnt += min(a[ci % 3], b[cj % 3]); } x += a[ci % 3], y += b[cj % 3]; ci++, cj++; } else if (x < y) { if ((ci + 1) % 3 == (cj + 2) % 3) { cnt += min(a[ci % 3], y - x); } x += a[ci % 3]; ci++; } else { if ((ci + 1 + 2) % 3 == cj % 3) { cnt += min(b[cj % 3], x - y); } y += b[cj % 3]; cj++; } } mx = max(mx, cnt), mn = min(mn, cnt); } } cout << mn << " " << mx << "\n"; } }