#include <bits/stdc++.h>
using namespace std;
void shuru_krte_hai_bina_kisi_bakchodi_ke() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
const long long mod = 1e9 + 7;
const long long s = 1e6 + 1;
int32_t main() {
  shuru_krte_hai_bina_kisi_bakchodi_ke();
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a, b, c;
    long long flag = 0;
    for (long long i = 0; i <= n; i++) {
      long long flag1 = 0;
      for (long long j = 0; j <= n; j++) {
        long long x = 3 * i + 5 * j;
        long long y = n - x;
        if (y >= 0 && y % 7 == 0) {
          a = i;
          b = j;
          c = y / 7;
          flag1 = 1;
          flag = 1;
        }
      }
      if (flag1) {
        break;
      }
    }
    if (!flag) {
      cout << -1 << "\n";
      continue;
    } else {
      cout << a << " " << b << " " << c << "\n";
    }
  }
  return 0;
}
