#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i <= 2; i++)
    for (int j = 0; j <= 2; j++) {
      if (n >= 5 * i + 7 * j && (n - 5 * i - 7 * j) % 3 == 0) {
        cout << (n - 5 * i - 7 * j) / 3 << " " << i << " " << j << '\n';
        return;
      }
    }
  cout << -1 << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
