#include<stdio.h>
#include<stdlib.h>
#define STACK_INIT_SIZE 20
#define STACKINCREMENT 10
typedef int Elemtype;
static int cnt = 1;
typedef struct{
char name;
Elemtype *base;
Elemtype *top;
int stacksize;
}sqStack;
void InitStack(sqStack &s, char name){
s.name = name ;
s.base = (Elemtype*)malloc(sizeof(Elemtype*));
if(!s.base) return ;
s.top = s.base;
s.stacksize = STACK_INIT_SIZE;
}
void Push(sqStack &s,Elemtype e){
if(s.top - s.base >= s.stacksize){
s.base = (Elemtype*)realloc(s.base,sizeof(Elemtype*)*(s.stacksize + STACKINCREMENT));
if(!s.base) return;
}
*s.top = e;
*s.top++;
}
void Pop(sqStack &s,Elemtype &e){
*s.top--;
e = *s.top;
}
void move(sqStack &a,sqStack &b){
Elemtype temp;
Pop(a,temp);
Push(b,temp);
}
void hanoi(int n,sqStack &x,sqStack &y,sqStack &z){
if(n == 1){
move(x,z);
printf("%d. Move disk %d from %c to %c\n",cnt++,n,x.name,z.name);
}
else{
hanoi(n-1,x,z,y);
move(x,z);
printf("%d. Move disk %d from %c to %c\n",cnt++,n,x.name,z.name);
hanoi(n-1,y,x,z);
}
}
int main(){
sqStack x,y,z;
InitStack(x,'x');
InitStack(y,'y');
InitStack(z,'z');
int n;
scanf("%d",&n);
hanoi(n,x,y,z);
return 0;
}