#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int t = 0;
    for (int i = 0; i <= 1000 / 3 && t == 0; i++) {
      for (int j = 0; j <= 1000 / 5 && t == 0; j++) {
        if (n >= i * 3 + j * 5 && (n - i * 3 - j * 5) % 7 == 0) {
          cout << i << " " << j << " " << (n - i * 3 - j * 5) / 7 << endl;
          t = 1;
          break;
        }
      }
    }
    if (!t) cout << "-1" << endl;
  }
  return 0;
}
