#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int tc;
  scanf("%lld", &tc);
  while (tc--) {
    long long int i, j, k, y, n, x, m, a, b, ans = 1, sum = 0, cnt = 0;
    string s, taj = "YES";
    cin >> n;
    long long int ara[9] = {0};
    while (n >= 3 and ans) {
      if (n % 5 == 0) {
        n /= 5;
        ara[5] += n;
        ans = 0;
        n = 0;
      } else if (n % 7 == 0) {
        n /= 7;
        ara[7] += n;
        ans = 0;
        n = 0;
      } else {
        n -= 3;
        ara[3]++;
      }
    }
    if (n)
      cout << -1 << endl;
    else
      cout << ara[3] << " " << ara[5] << " " << ara[7] << endl;
  }
  return 0;
}
