#include <bits/stdc++.h>
using namespace std;
int const N = 1e3 + 7;
bool res[N];
int par[N];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int i = 1; i <= 1000; ++i) res[i] = false, par[i] = 0;
  res[3] = res[5] = res[7] = true;
  for (int i = 4; i <= 1000; ++i)
    if (!res[i]) {
      if (i > 7 && res[i - 7])
        res[i] = true, par[i] = i - 7;
      else if (i > 5 && res[i - 5])
        res[i] = true, par[i] = i - 5;
      else if (i > 3 && res[i - 3])
        res[i] = true, par[i] = i - 3;
    }
  while (t--) {
    int n;
    cin >> n;
    if (res[n] == false) {
      cout << -1 << '\n';
      continue;
    }
    int a = 0, b = 0, c = 0;
    int node = n;
    for (int node = n; node != 0; node = par[node]) {
      int dif = node - par[node];
      if (dif == 3)
        a++;
      else if (dif == 5)
        b++;
      else
        c++;
    }
    cout << a << " " << b << " " << c << '\n';
  }
  return 0;
}
