#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int n[5] = {0};
const int N = 150;
void Pow(long long int *P){
for(int i = 0; i < N; ++i){
long long int i2 = i * i;
P[i] = i2 * i2 * i;
}
}
void logprint(int en, int* n, long long int *P) {
cout << en << "\t: ";
for (int i = 0; i < 5; ++i) cout << n[i] <<" ";
cout << " : " << P[N] << endl;
}
int * Eu(int be, int en, long long int *P, int *n, int j){
//logprint(j, n, P);
for (int i = be; i <= en; ++i){
if (n[4] != 0) return n;
P[N] += P[i]; n[j] = i;
if (j < 3)
n = Eu(i, en, P, n, j + 1);
else {
size_t k = lround(pow(P[N] + 1, 0.2));
if (P[k] == P[N] && k < N) n[4] = k;
}
P[N] -= P[i];
}
return n;
}
int * Eu(long long int *P, int en) {
n[4] = 0; P[N] = 0;
return Eu(1, en, P, n, 0);
}
int main(){
long long int P[N+1];
Pow(P);
int en;
cin >> en;
Eu(P, en);
for (int i = 0; i < 5; i++)
cout << n[i] << " ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDx2ZWN0b3I+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG5bNV0gPSB7MH07CmNvbnN0IGludCBOID0gMTUwOwoKdm9pZCBQb3cobG9uZyBsb25nIGludCAqUCl7Cglmb3IoaW50IGkgPSAwOyBpIDwgTjsgKytpKXsKCQlsb25nIGxvbmcgaW50IGkyID0gaSAqIGk7CgkJUFtpXSA9IGkyICogaTIgKiBpOwoJfQp9Cgp2b2lkIGxvZ3ByaW50KGludCBlbiwgaW50KiBuLCBsb25nIGxvbmcgaW50ICpQKSB7Cgljb3V0IDw8IGVuIDw8ICJcdDogIjsKCWZvciAoaW50IGkgPSAwOyBpIDwgNTsgKytpKSBjb3V0IDw8IG5baV0gPDwiICI7Cgljb3V0IDw8ICIgOiAiIDw8IFBbTl0gPDwgZW5kbDsKfQoKaW50ICogRXUoaW50IGJlLCBpbnQgZW4sIGxvbmcgbG9uZyBpbnQgKlAsIGludCAqbiwgaW50IGopewoJLy9sb2dwcmludChqLCBuLCBQKTsKICAgIGZvciAoaW50IGkgPSBiZTsgaSA8PSBlbjsgKytpKXsKICAgICAgICBpZiAobls0XSAhPSAwKSByZXR1cm4gbjsKICAgICAgICBQW05dICs9IFBbaV07IG5bal0gPSBpOwogICAgICAgIGlmIChqIDwgMykKCQkJbiA9IEV1KGksIGVuLCBQLCBuLCBqICsgMSk7CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIHNpemVfdCBrID0gbHJvdW5kKHBvdyhQW05dICsgMSwgMC4yKSk7CiAgICAgICAgICAgIGlmIChQW2tdID09IFBbTl0gJiYgayA8IE4pIG5bNF0gPSBrOwogICAgICAgIH0KICAgICAgICBQW05dIC09IFBbaV07CiAgICB9CiAgICByZXR1cm4gbjsKfQoKaW50ICogRXUobG9uZyBsb25nIGludCAqUCwgaW50IGVuKSB7CgluWzRdID0gMDsgUFtOXSA9IDA7CglyZXR1cm4gRXUoMSwgZW4sIFAsIG4sIDApOwp9CgppbnQgbWFpbigpewoJbG9uZyBsb25nIGludCBQW04rMV07CglQb3coUCk7CQoJaW50IGVuOwoJY2luID4+IGVuOwoJCglFdShQLCBlbik7CgkKCWZvciAoaW50IGkgPSAwOyBpIDwgNTsgaSsrKQoJCWNvdXQgPDwgbltpXSA8PCAiICI7CglyZXR1cm4gMDsKfQ==