#include <bits/stdc++.h>
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int mod = 10301;
int d[8], f[8];
bool isok(int a, int b, int c, int a2, int b2, int c2) {
  if (a < 0 || b < 0 || c < 0 || a2 < 0 || b2 < 0 || c2 < 0) return false;
  if (d[1] + d[4] > a + a2 || d[1] + d[6] > b + b2 || d[1] + d[7] > c + c2 ||
      d[1] > min({a, b, c}) + min({a2, b2, c2}))
    return false;
  int all = min({d[1], a, b, c});
  f[1] = all, f[4] = min(d[4], a - all), f[6] = min(d[6], b - all),
  f[7] = min(d[7], c - all);
  return true;
}
void process() {
  int a, b, c, a2, b2, c2;
  cin >> a >> b >> c;
  cin >> a2 >> b2 >> c2;
  for (int i = 1; i <= 7; i++) cin >> d[i];
  for (f[2] = 0; f[2] <= d[2]; f[2]++) {
    for (f[3] = 0; f[3] <= d[3]; f[3]++) {
      for (f[5] = 0; f[5] <= d[5]; f[5]++) {
        if (isok(a - f[2] - f[3], b - f[2] - f[5], c - f[3] - f[5],
                 a2 - d[2] - d[3] + f[2] + f[3], b2 - d[2] - d[5] + f[2] + f[5],
                 c2 - d[3] - d[5] + f[3] + f[5])) {
          for (int i = 1; i <= 7; i++) cout << f[i] << ' ';
          cout << '\n';
          return;
        }
      }
    }
  }
  cout << "-1\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) process();
}
