#include <bits/stdc++.h>
using namespace std;
inline int getint() {
  int ret = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while ('0' <= ch && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret;
}
int t, tmp;
int all_math;
int all_comp;
int all_PE;
int tmp_math;
int tmp_comp;
int tmp_PE;
int lim[2][3];
int d[9], f[9];
bool getans;
int main() {
  t = getint();
  while (t--) {
    lim[0][0] = getint();
    lim[0][1] = getint();
    lim[0][2] = getint();
    lim[1][0] = getint();
    lim[1][1] = getint();
    lim[1][2] = getint();
    for (int i = 1; i <= 7; ++i) scanf("%d", &d[i]);
    all_math = d[1] + d[2] + d[3] + d[4];
    all_comp = d[1] + d[2] + d[5] + d[6];
    all_PE = d[1] + d[3] + d[5] + d[7];
    getans = 0;
    if (all_math <= lim[0][0] + lim[1][0] &&
        all_comp <= lim[0][1] + lim[1][1] && all_PE <= lim[0][2] + lim[1][2]) {
      for (int s2 = 0; s2 <= d[2] && !getans; ++s2)
        for (int s3 = 0; s3 <= d[3]; ++s3) {
          f[2] = s2;
          f[3] = s3;
          tmp_math = f[2] + f[3];
          tmp_comp = f[2];
          tmp_PE = f[3];
          f[1] = min(d[1], min(lim[0][0] - tmp_math,
                               min(lim[0][1] - tmp_comp, lim[0][2] - tmp_PE)));
          tmp_math += f[1];
          tmp_comp += f[1];
          tmp_PE += f[1];
          f[5] = min(d[5], min(lim[0][1] - tmp_comp, lim[0][2] - tmp_PE));
          tmp_comp += f[5];
          tmp_PE += f[5];
          f[4] = min(lim[0][0] - tmp_math, d[4]);
          f[6] = min(lim[0][1] - tmp_comp, d[6]);
          f[7] = min(lim[0][2] - tmp_PE, d[7]);
          tmp_math += f[4];
          tmp_comp += f[6];
          tmp_PE += f[7];
          if (all_math - tmp_math <= lim[1][0] &&
              all_comp - tmp_comp <= lim[1][1] &&
              all_PE - tmp_PE <= lim[1][2]) {
            getans = 1;
            break;
          }
        }
    }
    if (getans)
      for (int i = 1; i <= 7; ++i) printf("%d%c", f[i], ((i < 7) ? ' ' : '\n'));
    else
      puts("-1");
  }
  return 0;
}
