#include using namespace std; #define MAX 16 int main() { long long nodes [16]; long long edges [16]; nodes[0] = 1; edges[0] = 0; for (int i = 1; i < MAX; ++i) { nodes[i] = 3*nodes[i-1]; edges[i] = edges[i-1] * 3 + 2 * nodes[i-1]; } int cargo; while (cin >> cargo) { int objects[MAX] = {0}; for (int i = MAX - 1; i >= 0; --i) { while (cargo - nodes[i] >= 0) { objects[i]++; cargo -= nodes[i]; } } bool print = false; for (int i = MAX -1; i >= 0; --i) { if (!print && objects[i]) { print = true; } if (print && i != 0) { cout << objects[i] << " "; } if (print && i == 0) { cout << objects[i]; } } cout << endl; } return 0; }