#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  int x3 = -1, x5 = 0, x7 = 0;
  for (int i = 0; 3 * i <= n; ++i) {
    for (int j = 0; 3 * i + 5 * j <= n; ++j) {
      int k = n - (3 * i + 5 * j);
      if (k % 7 == 0) x3 = i, x5 = j, x7 = k / 7;
    }
  }
  if (x3 == -1)
    puts("-1");
  else
    printf("%d %d %d\n", x3, x5, x7);
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
