#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main(void) {
  fast();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int f = -1;
    for (int i = 0; i <= n / 3; i++) {
      for (int j = 0; j <= n / 5; j++) {
        int y = n - 3 * i - 5 * j;
        if (y % 7 == 0) {
          cout << i << " " << j << " " << y / 7 << "\n";
          f = 1;
          break;
        }
      }
      if (f == 1) {
        break;
      }
    }
    if (f == -1) {
      cout << -1 << "\n";
    }
  }
}
