#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); long long all = 9872/8; int n = all*10; vector> V(n); for(int v=0; v use+use-sum) best = use+use-sum,V.at(v) = {a,b,c,d}; } } } if(v){ auto [a,b,c,d] = V.at(v); assert(a+b+c+d != 0); } //if(!ok){cout << v << " " << best << endl;} } int T; cin >> T; for(long long NN=8; NN<=T; NN+=8){ cout << NN << " "; long long N = NN; if(N%8){cout << "-1\n"; continue;} N /= 8; if(N < n){ auto [a,b,c,d] = V.at(N); long long use = max({a,b,c,d}),sum = a+b+c+d; assert(a+b*11+c*111+d*1111 == N); if(use+use >= sum) cout << "-1\n"; else cout << a << " " << b << " " << c << " " << d << "\n"; } else{ long long pos = N%all,memo = N; N -= n-all+pos; auto [a,b,c,d] = V.at(pos+n-all); assert(N%all == 0); N /= all; a += N,b += N,c += N,d += N; assert(a+b*11+c*111+d*1111 == memo); cout << a << " " << b << " " << c << " " << d << "\n"; } } }