#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a1, a2, b1, b2, c1, c2, d[8], f[8];
    int aa1, aa2, bb1, bb2, cc1, cc2, slx, srx, sly, sry, sl, sr;
    bool fg = 0;
    scanf("%d%d%d", &a1, &b1, &c1);
    scanf("%d%d%d", &a2, &b2, &c2);
    for (int i = 7; i > 0; --i) scanf("%d", &d[i]);
    for (int i = 0; i <= d[7]; ++i) {
      if (fg) break;
      for (int j = 0; j <= d[6]; ++j) {
        aa1 = a1 - (i + j);
        aa2 = a2 - (d[7] - i + d[6] - j);
        bb1 = b1 - (i + j);
        bb2 = b2 - (d[7] - i + d[6] - j);
        cc1 = c1 - i;
        cc2 = c2 - (d[7] - i);
        if (aa1 < 0 || aa2 < 0 || bb1 < 0 || bb2 < 0 || cc1 < 0 || cc2 < 0)
          continue;
        if (d[4] + d[5] > aa1 + aa2 || d[2] + d[3] > bb1 + bb2 ||
            d[1] + d[3] + d[5] > cc1 + cc2)
          continue;
        for (int op = 0; op < 8; ++op) {
          slx = 0;
          srx = d[5];
          sly = 0;
          sry = d[3];
          srx = min(srx, aa1);
          if (op & 1)
            slx = max(slx, aa1 - d[4]);
          else
            slx = max(slx, d[5] - aa2);
          sry = min(sry, bb1);
          if (op & 2)
            sly = max(sly, bb1 - d[2]);
          else
            sly = max(sly, d[3] - bb2);
          if (slx > srx || sly > sry) continue;
          sl = slx + sly;
          sr = srx + sry;
          sr = min(sr, cc1);
          if (op & 4)
            sl = max(sl, cc1 - d[1]);
          else
            sl = max(sl, d[3] + d[5] - cc2);
          if (sl > sr) continue;
          fg = 1;
          for (int x = slx; x <= srx; ++x) {
            int dl = sl - x, dr = sr - x;
            dl = max(dl, sly);
            dr = min(dr, sry);
            if (dl <= dr) {
              f[7] = i;
              f[6] = j;
              f[5] = x;
              f[3] = dl;
              f[4] = min(d[4], aa1 - x);
              f[2] = min(d[2], bb1 - dl);
              f[1] = min(d[1], cc1 - x - dl);
              for (int k = 7; k > 0; --k) printf("%d%c", f[k], " \n"[k == 1]);
              break;
            }
          }
          break;
        }
        if (fg) break;
      }
    }
    if (!fg) puts("-1");
  };
  return 0;
}
