#include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin>>N;
vector<int> V;
V.push_back(N);
while(N > 1)
{
if(N%2 == 0)
{
N=N/2;
}
else
{
N=3*N+1;
}
V.push_back(N);
}
for(int i=0;i<V.size();i++)
{
if(i != V.size()-1)
{
cout<<V[i]<<" ";
}
else
{
cout<<V[i]<<endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgkKCWludCBOOwoJY2luPj5OOwoJCgl2ZWN0b3I8aW50PiBWOwoJVi5wdXNoX2JhY2soTik7Cgl3aGlsZShOID4gMSkKCXsKCQlpZihOJTIgPT0gMCkKCQl7CgkJCU49Ti8yOwoJCX0KCQllbHNlCgkJewoJCQlOPTMqTisxOwoJCX0KCQlWLnB1c2hfYmFjayhOKTsKCX0KCQoJZm9yKGludCBpPTA7aTxWLnNpemUoKTtpKyspCgl7CgkJaWYoaSAhPSBWLnNpemUoKS0xKQoJCXsKCQkJY291dDw8VltpXTw8IiAiOwoJCX0KCQllbHNlCgkJewoJCQljb3V0PDxWW2ldPDxlbmRsOwoJCX0KCX0KCQoJCglyZXR1cm4gMDsKfQ==