#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
long long int const mod = 998244353;
long long int const maxn = 5e5 + 7;
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      int x = n - i * 3 - j * 5;
      if (x % 7 == 0 and x >= 0) {
        cout << i << " " << j << " " << x / 7 << endl;
        return;
      }
    }
  }
  cout << -1 << endl;
  return;
}
int main() {
  int tc;
  cin >> tc;
  while (tc--) solve();
}
