#include <bits/stdc++.h>
using namespace std;
const long long ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const double eps = 1e-7;
const int N = 2e6 + 6;
int a[3], b[3], d[8];
bool check(int i, int j, int k) {
  for (int i = 0; i <= 2; ++i)
    if (a[i] < 0 || b[i] < 0) return 0;
  if (a[0] + b[0] < d[7] + d[1]) return 0;
  if (a[1] + b[1] < d[7] + d[2]) return 0;
  if (a[2] + b[2] < d[7] + d[4]) return 0;
  if (min(a[0], min(a[1], a[2])) + min(b[0], min(b[1], b[2])) < d[7]) return 0;
  int val = min(min(a[0], min(a[1], a[2])), d[7]);
  cout << val << " ";
  cout << k << " ";
  cout << j << " ";
  cout << min(a[2] - val, d[4]) << " ";
  cout << i << " ";
  cout << min(a[1] - val, d[2]) << " ";
  cout << min(a[0] - val, d[1]) << "\n";
  return 1;
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    for (int i = 2; i >= 0; --i) cin >> a[i];
    for (int i = 2; i >= 0; --i) cin >> b[i];
    for (int i = 0; i <= 6; ++i) cin >> d[i ^ 7];
    bool found = 0;
    for (int i = 0; i <= d[3]; ++i) {
      a[0] -= i;
      b[0] -= d[3] - i;
      a[1] -= i;
      b[1] -= d[3] - i;
      for (int j = 0; j <= d[5]; ++j) {
        a[0] -= j;
        b[0] -= d[5] - j;
        a[2] -= j;
        b[2] -= d[5] - j;
        for (int k = 0; k <= d[6]; ++k) {
          a[1] -= k;
          b[1] -= d[6] - k;
          a[2] -= k;
          b[2] -= d[6] - k;
          if (check(i, j, k)) {
            found = 1;
            break;
          }
          a[1] += k;
          b[1] += d[6] - k;
          a[2] += k;
          b[2] += d[6] - k;
        }
        if (found) break;
        a[0] += j;
        b[0] += d[5] - j;
        a[2] += j;
        b[2] += d[5] - j;
      }
      if (found) break;
      a[0] += i;
      b[0] += d[3] - i;
      a[1] += i;
      b[1] += d[3] - i;
    }
    if (!found) cout << "-1\n";
  }
  return 0;
}
