#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, flag = 0;
    vector<int> v;
    cin >> n;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        if ((n - (7 * i + 5 * j)) % 3 == 0 && (n - (7 * i + 5 * j)) >= 0) {
          flag = 1;
          v.push_back((n - 7 * i - 5 * j) / 3);
          v.push_back(j);
          v.push_back(i);
          break;
        }
      }
      if (flag == 1) {
        break;
      }
    }
    if (flag == 1) {
      cout << v[0] << " " << v[1] << " " << v[2] << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
