#include <bits/stdc++.h>
using namespace std;
const int maxn = 1200 + 5;
const int Size = 20;
int main() {
  std::ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    bool flag = false;
    for (int i = 0; i <= 340; i++) {
      for (int j = 0; j <= 200; j++) {
        int r = n - 3 * i - 5 * j;
        r /= 7;
        if (n == r * 7 + i * 3 + j * 5 && r >= 0) {
          cout << i << ' ' << j << ' ' << r << endl;
          flag = 1;
          break;
        }
      }
      if (flag) break;
    }
    if (!flag) cout << -1 << endl;
  }
  return 0;
}
