#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
const long long X = 1000;
cin >> N;
if (N == 0) {
cout << 0;
return 0;
}
// Phân tích số thành các hệ số theo cơ số X
vector<long long> x;
long long num = N;
while (num != 0) {
long long a = num % X;
num /= X;
// Điều chỉnh hệ số để nằm trong khoảng -X/2 < a <= X/2
if (a > X / 2) {
a -= X;
num += 1;
}
else if (a < -X / 2) {
a += X;
num -= 1;
}
x.push_back(a);
}
// Xây dựng chuỗi đa thức
string ans = "";
int degree = (int)x.size() - 1;
for (int i = degree; i >= 0; --i) {
long long coeff = x[i];
if (coeff == 0) continue;
// Xử lý dấu
if (!ans.empty()) {
if (coeff > 0)
ans += " + ";
else {
ans += " - ";
coeff = -coeff;
}
}
else {
if (coeff < 0) {
ans += "-";
coeff = -coeff;
}
}
// Xử lý hệ số
if (!(coeff == 1 && i != 0))
ans += to_string(coeff);
// Xử lý biến và số mũ
if (i > 0) {
ans += "x";
if (i > 1)
ans += "^" + to_string(i);
}
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cglsb25nIGxvbmcgTjsKCWNvbnN0IGxvbmcgbG9uZyBYID0gMTAwMDsKCWNpbiA+PiBOOwoKCWlmIChOID09IDApIHsKCQljb3V0IDw8IDA7CgkJcmV0dXJuIDA7Cgl9CgoJLy8gUGjDom4gdMOtY2ggc+G7kSB0aMOgbmggY8OhYyBo4buHIHPhu5EgdGhlbyBjxqEgc+G7kSBYCgl2ZWN0b3I8bG9uZyBsb25nPiB4OwoJbG9uZyBsb25nIG51bSA9IE47Cgl3aGlsZSAobnVtICE9IDApIHsKCQlsb25nIGxvbmcgYSA9IG51bSAlIFg7CgkJbnVtIC89IFg7CgkJLy8gxJBp4buBdSBjaOG7iW5oIGjhu4cgc+G7kSDEkeG7gyBu4bqxbSB0cm9uZyBraG/huqNuZyAtWC8yIDwgYSA8PSBYLzIK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