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