#include <bits/stdc++.h>
using namespace std;
bool boo = false;
bool solve(int x, int a, int b, int c) {
  if (x == 0) {
    cout << a << " " << b << " " << c << endl;
    return true;
  }
  if (x < 0) return false;
  if (solve(x - 3, a + 1, b, c) == true) {
    return true;
  }
  if (solve(x - 5, a, b + 1, c)) {
    return true;
  }
  if (solve(x - 7, a, b, c + 1)) return true;
  return false;
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    int t;
    cin >> t;
    if (solve(t, 0, 0, 0) == false) cout << "-1" << endl;
  }
  return 0;
}
