#include <bits/stdc++.h>
using namespace std;
int vis[1005];
int x[1005];
int y[1005];
int z[1005];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  for (int i = 0; i <= 1010 / 3; i++) {
    for (int j = 0; j <= 1010 / 5; j++) {
      for (int k = 0; k <= 1010 / 7; k++) {
        int sum = 3 * i + 5 * j + 7 * k;
        if (sum > 1000)
          break;
        else if (vis[sum] == 0) {
          vis[sum]++;
          x[sum] = i;
          y[sum] = j;
          z[sum] = k;
        }
      }
    }
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (vis[n])
      cout << x[n] << " " << y[n] << " " << z[n] << endl;
    else
      cout << "-1" << endl;
  }
}
