#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, k, f = 0, g = 0, h = 0;
    cin >> n;
    int p = n / 3;
    int q = n / 5;
    int r = n / 7;
    for (i = 0; i <= p; i++) {
      for (j = 0; j <= q; j++) {
        for (k = 0; k <= r; k++) {
          if (i * 3 + j * 5 + k * 7 == n) {
            f = 1;
            break;
          }
        }
        if (f == 1) {
          g = 1;
          break;
        }
      }
      if (g == 1) {
        h = 1;
        break;
      }
    }
    if (h == 1)
      cout << i << " " << j << " " << k << endl;
    else
      cout << -1 << endl;
  }
}
