#include <bits/stdc++.h>
using namespace std;
int A1, B1, C1;
int A2, B2, C2;
int T1, T2, T3, T4, T5, T6, T7;
bool check(int t2, int t3, int t5) {
int xa0 = A1 - t2 - t3, xa1 = A2 - (T2 - t2) - (T3 - t3);
int xb0 = B1 - t2 - t5, xb1 = B2 - (T2 - t2) - (T5 - t5);
int xc0 = C1 - t3 - t5, xc1 = C2 - (T5 - t5) - (T3 - t3);
int L1 = max(0, T1 + T4 - xa1), R1 = xa0;
int L2 = max(0, T1 + T6 - xb1), R2 = xb0;
int L3 = max(0, T1 + T7 - xc1), R3 = xc0;
if(R1 < L1 || R2 < L2 || R3 < L3)return 0;
int t1 = min({T1, max({L1, L2, L3}), min({R1, R2, R3})});
int t4 = max(0, L1 - t1);
int t6 = max(0, L2 - t1);
int t7 = max(0, L3 - t1);
if (t1 + t4 <= R1 && t1 + t6 <= R2 && t1 + t7 <= R3 && t4 <= T4 && t6 <= T6 && t7 <= T7) {
cout << t1 << " " << t2 << " " << t3 << " " << t4 << " " << t5 << " " << t6 << " " << t7 << "\n";
return 1;
}
return 0;
}
void solve() {
cin >> A1 >> B1 >> C1;
cin >> A2 >> B2 >> C2;
cin >> T1 >> T2 >> T3 >> T4 >> T5 >> T6 >> T7;
for(int t2 = 0; t2 <= T2; t2++) {
for(int t3 = 0; t3 <= T3; t3++) {
for(int t5 = 0; t5 <= T5; t5++) {
if(check(t2, t3, t5))
return;
}
}
}
cout << -1 << "\n";
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while(t--) {
solve();
}
}
1343C - Alternating Subsequence | 1325A - EhAb AnD gCd |
746A - Compote | 318A - Even Odds |
550B - Preparing Olympiad | 939B - Hamster Farm |
732A - Buy a Shovel | 1220C - Substring Game in the Lesson |
452A - Eevee | 1647B - Madoka and the Elegant Gift |
1408A - Circle Coloring | 766B - Mahmoud and a Triangle |
1618C - Paint the Array | 469A - I Wanna Be the Guy |
1294A - Collecting Coins | 1227A - Math Problem |
349A - Cinema Line | 47A - Triangular numbers |
1516B - AGAGA XOOORRR | 1515A - Phoenix and Gold |
1515B - Phoenix and Puzzle | 155A - I_love_username |
49A - Sleuth | 1541A - Pretty Permutations |
1632C - Strange Test | 673A - Bear and Game |
276A - Lunch Rush | 1205A - Almost Equal |
1020B - Badge | 1353A - Most Unstable Array |