#include using namespace std; /* #include using namespace atcoder; */ #define rep(i,n) for(int i=0;i; using ll = long long; using ull = unsigned long long; //*/ template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef pair pii; typedef pair pll; typedef vector vll; typedef vector vint; const int INF=1001001001; int a[3],b[3]; //FordFulkerson g(n);で初期化 //g.add_edge(a, b, c);でa->bに重みcの辺を張る //g.max_flow(s,t);でs->tでの最大流 template< typename flow_t > struct FordFulkerson { struct edge { int to; flow_t cap; int rev; bool isrev; int idx; }; vector< vector< edge > > graph; vector< int > used; const flow_t INF; int timestamp; FordFulkerson(int n) : INF(numeric_limits< flow_t >::max()), timestamp(0) { graph.resize(n); used.assign(n, -1); } void add_edge(int from, int to, flow_t cap, int idx = -1) { graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx}); graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx}); } flow_t dfs(int idx, const int t, flow_t flow) { if(idx == t) return flow; used[idx] = timestamp; for(auto &e : graph[idx]) { if(e.cap > 0 && used[e.to] != timestamp) { flow_t d = dfs(e.to, t, min(flow, e.cap)); if(d > 0) { e.cap -= d; graph[e.to][e.rev].cap += d; return d; } } } return 0; } flow_t max_flow(int s, int t) { flow_t flow = 0; for(flow_t f; (f = dfs(s, t, INF)) > 0; timestamp++) { flow += f; } return flow; } void output() { for(int i = 0; i < graph.size(); i++) { for(auto &e : graph[i]) { if(e.isrev) continue; auto &rev_e = graph[e.to][e.rev]; cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl; } } } }; void solve(){ rep(i,3) cin >> a[i]; rep(i,3) cin >> b[i]; int n = a[0] + a[1] + a[2]; FordFulkerson g(8); rep(i,3) g.add_edge(6,i,a[i]); rep(i,3) g.add_edge(i+3,7,b[i]); rep(i,3)rep(j,3)if((i+1)%3 != j) g.add_edge(i,j+3,1001001001); int mx = g.max_flow(6,7); cout << n-mx << " "; int mn = 0; rep(i,3)rep(j,3)if((i+1)%3 == j) mn += min(a[i],b[j]); cout << mn << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; cin >> t; rep(i,t) solve(); }