func_code_string: #include <bits/stdc++.h>   long long gi() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) f ^= ch ==  - , ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f ? x : -x;   }   std::mt19937 rnd(time(NULL));   template <class T>   void cxk(T& a, T b) {     a = a > b ? a : b;   }   template <class T>   void cnk(T& a, T b) {     a = a < b ? a : b;   }   int A[2][3], B[8], C[3];   int main() {     int qwq = gi();     while (qwq--) {       for (int i = 0; i < 2; ++i)         for (int j = 2; ~j; --j) A[i][j] = gi();       for (int j = 7; j; --j) B[j] = gi();       int s = 0;       for (int i = 1; i <= 7; ++i)         if (i != (i & -i)) s += B[i];       for (int i = 0; i < 3; ++i) {         int sum = A[0][i] + A[1][i];         for (int j = 1; j <= 7; ++j)           if (j >> i & 1) sum -= B[j];         if (sum < 0) {           puts( -1 );           goto ed;         }       }       for (int i = 0; i < 3; ++i) C[i] = B[7 ^ (1 << i)];       for (int a = 0, b = s; a <= s; ++a, --b) {         bool flg = 0;         for (int i = 0; i < 3; ++i)           if (std::max(0, a - A[0][i]) + std::max(0, b - A[1][i]) > C[i]) flg = 1;         if (a < std::max(0, a - A[0][0]) + std::max(0, a - A[0][1]) +                     std::max(0, a - A[0][2]))           flg = 1;         if (b < std::max(0, b - A[1][0]) + std::max(0, b - A[1][1]) +                     std::max(0, b - A[1][2]))           flg = 1;         if (flg) continue;         int D[8] = {0};         D[7] = a;         for (int i = 0; i < 3; ++i) {           int p = std::max(0, a - A[0][i]);           D[7 ^ (1 << i)] = p;           D[7] -= p;         }         for (int i = 0; i < 3; ++i) {           int p = std::max(               0, std::min({D[7] - B[7], B[7 ^ (1 << i)] - D[7 ^ (1 << i)],                            C[i] - D[7 ^ (1 << i)] - std::max(0, b - A[1][i])}));           D[7 ^ (1 << i)] += p;           D[7] -= p;         }         for (int i = 0; i < 3; ++i) {           int s = A[0][i];           for (int j = 1; j <= 7; ++j)             if (j >> i & 1) s -= D[j];           D[1 << i] = std::min(s, B[1 << i]);         }         for (int i = 7; i; --i) printf( %d  , D[i]);         puts(  );         for (int i = 1; i <= 7; ++i) assert(D[i] <= B[i]);         for (int i = 0; i < 3; ++i) {           int s1 = 0, s2 = 0;           for (int j = 1; j <= 7; ++j)             if (j >> i & 1) s1 += D[j], s2 += B[j] - D[j];           assert(s1 <= A[0][i] && s2 <= A[1][i]);         }         goto ed;       }       puts( -1 );     ed:;     }     return 0;   }   