#include <iostream>
using namespace std;
int t;
int n;
bool find(int n) {
for(int x = 0; x <= n / 3; ++x)
for(int y = 0; y <= n / 5; ++y)
for(int z = 0; z <= n / 7; ++z)
if(7 * z + 5 * y + 3 * x == n) {
cout << x << ' ' << y << ' ' << z << endl;
return true;
}
return false;
}
int main()
{
cin >> t;
while(t--) {
cin >> n;
if(find(n)) continue;
else cout << -1 << endl;
}
return 0;
}