#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n % 3 == 0) {
      cout << n / 3 << " " << 0 << " " << 0 << endl;
      continue;
    }
    if (n % 5 == 0) {
      cout << 0 << " " << n / 5 << " " << 0 << endl;
      continue;
    }
    if (n % 7 == 0) {
      cout << 0 << " " << 0 << " " << n / 7 << endl;
      continue;
    }
    if (n < 8) {
      cout << -1 << endl;
      continue;
    }
    int five = (n / 3 - 1) * 3;
    int seven = (n / 3 - 2) * 3;
    if (five + 5 == n) {
      cout << n / 3 - 1 << " " << 1 << " " << 0 << endl;
    } else if (seven + 7 == n) {
      cout << n / 3 - 2 << " " << 0 << " " << 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
