//P5727
#include<stdio.h>
int main()
{
int n,num;
int A[100000];int i=1;
scanf("%d",&n);
num=n;A[0]=n;
while(num!=1)
{
if(num%2==0)num/=2;
else num=num*3+1;
A[i++]=num;
}
while(i--)printf("%d ",A[i]);
return 0;
}
//P5727
#include<stdio.h>
int main()
{
int n,num;
int A[100000];int i=1;
scanf("%d",&n);
num=n;A[0]=n;
while(num!=1)
{
if(num%2==0)num/=2;
else num=num*3+1;
A[i++]=num;
}
while(i--)printf("%d ",A[i]);
return 0;
}