#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
int a1, b1, c1;
int a2, b2, c2;
int d1, d2, d3, d4, d5, d6, d7;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tests;
  cin >> tests;
  while (tests--) {
    cin >> a1 >> b1 >> c1;
    cin >> a2 >> b2 >> c2;
    cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6 >> d7;
    int xL = max(0, d1 + d2 + d3 + d4 - a2);
    int xR = min(d1 + d2 + d3 + d4, a1);
    int yL = max(0, d1 + d2 + d5 + d6 - b2);
    int yR = min(d1 + d2 + d5 + d6, b1);
    int zL = max(0, d1 + d3 + d5 + d7 - c2);
    int zR = min(d1 + d3 + d5 + d7, c1);
    if (xL > xR || yL > yR || zL > zR) {
      cout << "-1\n";
      continue;
    }
    bool found = false;
    for (int f2 = 0; f2 <= d2; f2++)
      for (int f3 = 0; f3 <= d3 && f2 + f3 <= xR; f3++)
        for (int f5 = 0; f5 <= d5 && f2 + f5 <= yR && f3 + f5 <= zR; f5++) {
          int x = f2 + f3, y = f2 + f5, z = f3 + f5;
          int f1 = max(0, min(min(d1, xR - x), min(yR - y, zR - z)));
          x += f1;
          y += f1;
          z += f1;
          int f4 = max(0, min(d4, xR - x));
          x += f4;
          int f6 = max(0, min(d6, yR - y));
          y += f6;
          int f7 = max(0, min(d7, zR - z));
          z += f7;
          if (x >= xL && x <= xR && y >= yL && y <= yR && z >= zL && z <= zR) {
            found = true;
            cout << f1 << ' ' << f2 << ' ' << f3 << ' ' << f4 << ' ' << f5
                 << ' ' << f6 << ' ' << f7 << '\n';
            f2 = d2 + 1;
            f3 = d3 + 1;
            break;
          }
        }
    if (!found) {
      cout << "-1\n";
      continue;
    }
  }
  return 0;
}
