【題目敘述】http://codeforces.com/contest/1401/problem/B
#include <iostream>
using namespace std;
int t, a[3], b[3];
int main() {
cin >> t;
while (t--){
int tot = 0;
for (int i = 0; i < 3; i++){
cin >> a[i];
tot += a[i];
}
for (int i = 0; i < 3; i++){
cin >> b[i];
}
int tmp = min(a[2], b[1]);
int ans = tmp*2;
tot -= tmp;
if (b[2] > tot-a[1]) ans -= (b[2]-(tot-a[1]))*2;
cout << ans << "\n";
}
}