#include<bits/stdc++.h> 
using namespace std;
int n;
char name(int x)
{
    if(x==1) return 'A';
    if(x==2) return 'B';
    else return 'C';
}
void move(int from,int to,int tran,int x)
{
    if(x==0) return;
    move(from,tran,to,x-1);
    printf("move %d from %c to %c\n",x,name(from),name(to));
    move(tran,to,from,x-1);
}
int main()
{
    cin>>n;
    move(1,3,2,n);
    return 0;
}