#include <bits/stdc++.h>
using namespace std;
int main() {
int x; cin >> x;
string a = "";
while(x){
char c = char((x % 8) + '0');
cout << x % 8 << '\n';
cout << c << '\n';
x /= 8;
}
cout << a;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB4OyBjaW4gPj4geDsKCXN0cmluZyBhID0gIiI7Cgl3aGlsZSh4KXsKCQljaGFyIGMgPSBjaGFyKCh4ICUgOCkgKyAnMCcpOwoJCWNvdXQgPDwgeCAlIDggPDwgJ1xuJzsKCQljb3V0IDw8IGMgPDwgJ1xuJzsKCQl4IC89IDg7Cgl9Cgljb3V0IDw8IGE7CglyZXR1cm4gMDsKfQ==