#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int sum;
    cin >> sum;
    int threeMax = sum / 3;
    int sevenMax = sum / 7;
    bool notFound = true;
    for (int i = 0; i <= threeMax && notFound; i++) {
      int remainingAfterThree = sum - i * 3;
      int fiveMax = remainingAfterThree / 5;
      for (int j = 0; j <= fiveMax && notFound; j++) {
        int remainingAfterFive = remainingAfterThree - j * 5;
        int sevenMax = remainingAfterFive / 7;
        for (int k = 0; k <= sevenMax && notFound; k++) {
          if (remainingAfterFive == 7 * k) {
            cout << i << " " << j << " " << k << endl;
            notFound = false;
          }
        }
      }
    }
    if (notFound) {
      cout << "-1" << endl;
    }
  }
  return 0;
}
