#include <bits/stdc++.h>
const int N = 2050;
using namespace std;
long long n, k, sum, q, res, m, val, ans;
long long x, y;
double p;
long long xx[] = {1, 0, -1, 0};
long long yy[] = {0, 1, 0, -1};
void solve() {
  cin >> n;
  for (int i = 0; i <= (n / 3); i++) {
    for (int j = 0; j <= (n / 5); j++) {
      long long res = (i * 3) + (j * 5);
      long long res2 = (n - res);
      if (res2 >= 0 and res2 % 7 == 0) {
        cout << i << " " << j << " " << (res2 / 7) << "\n";
        return;
      }
    }
  }
  cout << "-1\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) solve();
}
