#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
void solve() {
  int A[2], B[2], C[2], d[7];
  for (int i = 0; i < (int)(2); ++i) scanf(" %d %d %d", &A[i], &B[i], &C[i]);
  for (int i = 0; i < (int)(7); ++i) scanf(" %d", &d[i]);
  int a[2], b[2], c[2], x[2][7];
  for (int ii = 0; ii < (int)(d[1] + 1); ++ii)
    for (int jj = 0; jj < (int)(d[2] + 1); ++jj)
      for (int kk = 0; kk < (int)(d[4] + 1); ++kk) {
        for (int i = 0; i < (int)(2); ++i) {
          a[i] = A[i];
          b[i] = B[i];
          c[i] = C[i];
        }
        x[0][1] = ii;
        x[1][1] = d[1] - ii;
        x[0][2] = jj;
        x[1][2] = d[2] - jj;
        x[0][4] = kk;
        x[1][4] = d[4] - kk;
        bool ok = true;
        for (int i = 0; i < (int)(2); ++i) {
          a[i] -= x[i][1] + x[i][2];
          b[i] -= x[i][1] + x[i][4];
          c[i] -= x[i][2] + x[i][4];
          if (a[i] < 0 || b[i] < 0 || c[i] < 0) ok = false;
        }
        if (!ok) continue;
        x[0][0] = min({a[0], b[0], c[0], d[0]});
        x[1][0] = d[0] - x[0][0];
        for (int i = 0; i < (int)(2); ++i) {
          a[i] -= x[i][0];
          b[i] -= x[i][0];
          c[i] -= x[i][0];
          if (a[i] < 0 || b[i] < 0 || c[i] < 0) ok = false;
        }
        if (!ok) continue;
        x[0][3] = min(a[0], d[3]);
        x[1][3] = d[3] - x[0][3];
        x[0][5] = min(b[0], d[5]);
        x[1][5] = d[5] - x[0][5];
        x[0][6] = min(c[0], d[6]);
        x[1][6] = d[6] - x[0][6];
        for (int i = 0; i < (int)(2); ++i) {
          a[i] -= x[i][3];
          b[i] -= x[i][5];
          c[i] -= x[i][6];
          if (a[i] < 0 || b[i] < 0 || c[i] < 0) ok = false;
        }
        if (ok) {
          for (int i = 0; i < (int)(7); ++i)
            printf("%d%c", x[0][i], " \n"[i == 6]);
          return;
        }
      }
  printf("-1\n");
  return;
}
int main() {
  int t;
  scanf(" %d", &t);
  while (t--) solve();
  return 0;
}
