#include <bits/stdc++.h>
using namespace std;
long long int modmulti(long long int a, long long int b, long long int m) {
  return ((a % m) * (b % m)) % m;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int power(long long int x, long long int y, long long int m) {
  if (y == 0) return 1;
  long long int p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
long long int power2(long long int x, long long int y) {
  if (y == 0) return 1;
  long long int p = power2(x, y / 2);
  p = (p * p);
  return (y % 2 == 0) ? p : (x * p);
}
bool cmp(pair<double, double>& a, pair<double, double>& b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first > b.first;
}
long long int findclosest(long long int n) {
  long long int i;
  for (i = 0; i <= 64; i++) {
    if (power2(2, i) <= n)
      continue;
    else
      break;
  }
  return power2(2, i - 1);
}
long long int get_signi(long long int n) {
  while (n >= 10) {
    n = n / 10;
  }
  return n;
}
long long int get_digits(long long int n) {
  long long int i = 0;
  while (n >= 10) {
    n = n / 10;
    i++;
  }
  return i;
}
bool is_palindrome(string t) {
  for (int i = 0; i < t.size() / 2; i++) {
    if (t[i] != t[t.size() - i - 1]) return false;
  }
  return true;
}
long long int factorial(long long int n) {
  if (n == 0) return 1;
  long long int i = n, fact = 1;
  while (n / i != n) {
    fact = ((fact % 1000000007) * (i % 1000000007)) % 1000000007;
    i--;
  }
  return fact % 1000000007;
}
long long int findpow(long long int n) {
  long long int cnt = 0;
  while (n != 0) {
    n /= 2;
    cnt++;
  }
  return cnt - 1;
}
bool isPrime(long long int n) {
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long int digit_sum(long long int n) {
  long long int sum = 0;
  while (n != 0) {
    sum += n % 10;
    n = n / 10;
  }
  return sum;
}
const long long int MOD = 1000000007;
const int SUP = 100006;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int cnt = 0;
    bool flag = false, flag2 = false;
    while (n >= 5) {
      if (n % 7 == 0) {
        flag = true;
        break;
      }
      if (n % 3 == 0) {
        flag2 = true;
        break;
      }
      cnt++;
      n -= 5;
    }
    if (n % 3 == 0) flag2 = true;
    if (n % 7 == 0) flag = true;
    if (flag)
      cout << 0 << " " << cnt << " " << n / 7 << "\n";
    else if (flag2)
      cout << n / 3 << " " << cnt << " " << 0 << "\n";
    else if (n == 0)
      cout << 0 << " " << cnt << " " << 0 << "\n";
    else
      cout << -1 << "\n";
  }
  return 0;
}
