#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n % 3 == 0) {
      cout << n / 3 << " " << 0 << " " << 0 << endl;
    } else if (n % 5 == 0)
      cout << 0 << " " << n / 5 << " " << 0 << endl;
    else if (n % 7 == 0)
      cout << 0 << " " << 0 << " " << n / 7 << endl;
    else {
      int c3 = 0, c5 = 0, c7 = 0;
      int e = 1;
      while (e--) {
        n = n - 7;
        if (n < 0) {
          cout << -1 << endl;
          break;
        }
        if (n % 5 == 0) {
          cout << 0 << " " << n / 5 << " " << 1 << endl;
          c5 = 1;
          break;
        } else if (n % 3 == 0) {
          cout << n / 3 << " " << 0 << " " << 1 << endl;
          c5 = 1;
          break;
        }
        n += 7;
        n = n - 5;
        if (n % 7 == 0) {
          cout << 0 << " " << 1 << " " << n / 7 << endl;
          c5 = 1;
          break;
        } else if (n % 3 == 0) {
          cout << n / 3 << " " << 1 << " " << 0 << endl;
          c5 = 1;
          break;
        }
        n += 5;
        n = n - 3;
        if (n % 7 == 0) {
          cout << 1 << " " << 0 << " " << n / 7 << endl;
          c5 = 1;
          break;
        } else if (n % 5 == 0) {
          cout << 1 << " " << n / 5 << " " << 0 << endl;
          c5 = 1;
          break;
        }
        cout << -1 << endl;
        break;
      }
    }
  }
}
