#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a, b, c, f = 0;
    for (int i = 0; i <= n / 3; i++) {
      int k = n - 3 * i;
      for (int j = 0; j <= k / 5; j++) {
        int l = k - j * 5;
        if (l % 7 == 0) {
          a = i;
          b = j;
          c = l / 7;
          f = 1;
          break;
        }
      }
    }
    if (f == 0) {
      cout << -1 << endl;
    } else {
      cout << a << " " << b << " " << c << endl;
    }
  }
  return 0;
}
