#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
int temp=n;
int bb[1000];
int i=1;
int j;
bb[0]=n;
while(1){
if(temp%2!=0){
temp=temp*3+1;
bb[i]=temp;
}else{
temp=temp/2;
bb[i]=temp;
}
i++;
if(temp==1){
break;
}
}
j=i;
for(int i=0;i<j/2;i++){
int t=bb[i];
bb[i]=bb[j-1-i];
bb[j-1-i]=t;
}
for(int h=0;h<j;h++){
printf("%d ",bb[h]);
}
}