#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int a0, a1, a2, b0, b1, b2, ex0, ex1, ex2, ever, only0, only1, only2;
    cin >> a0 >> a1 >> a2 >> b0 >> b1 >> b2 >> ever >> ex2 >> ex1 >> only0 >>
        ex0 >> only1 >> only2;
    int s0 = ever + ex1 + ex2 + only0, s1 = ever + ex0 + ex2 + only1,
        s2 = ever + ex0 + ex1 + only2;
    if (s0 > a0 + b0 || s1 > a1 + b1 || s2 > a2 + b2) {
      cout << "-1\n";
      continue;
    }
    int anime = ever + ex0 + ex1 + ex2;
    bool ok = false;
    for (int i = 0; i <= anime; i++) {
      int luex0 = i + max(-a0, ex0 - anime),
          ruex0 = ex0 + min(0, b0 + i - anime),
          luex1 = i + max(-a1, ex1 - anime),
          ruex1 = ex1 + min(0, b1 + i - anime),
          luex2 = i + max(-a2, ex2 - anime),
          ruex2 = ex2 + min(0, b2 + i - anime);
      luex0 = max(0, luex0);
      luex1 = max(0, luex1);
      luex2 = max(0, luex2);
      if (luex0 > ruex0 || luex1 > ruex1 || luex2 > ruex2 ||
          min(i, ruex0 + ruex1 + ruex2) <
              max(max(0, i - ever), luex0 + luex1 + luex2))
        continue;
      int uex0 = max(luex0, max(0, i - ever) - ruex1 - ruex2),
          uex1 = max(luex1, max(0, i - ever) - uex0 - ruex2),
          uex2 = max(luex2, max(0, i - ever) - uex0 - uex1);
      int uonly0 = min(only0, a0 - i + uex0),
          uonly1 = min(only1, a1 - i + uex1),
          uonly2 = min(only2, a2 - i + uex2);
      ok = true;
      cout << i - uex0 - uex1 - uex2 << " " << uex2 << " " << uex1 << " "
           << uonly0 << " " << uex0 << " " << uonly1 << " " << uonly2 << "\n";
      break;
    }
    if (!ok) cout << "-1\n";
  }
  return 0;
}
