import java.util.*;
public class Main {
public static void towerOfHanoi(int n,char from_peg, char to_peg,char aux_peg)
{
if(n==1)
{
System.out.println("move ring 1 from "+ from_peg + " to "+ to_peg);
return;
}
towerOfHanoi(n-1, from_peg, aux_peg, to_peg);
System.out.println("Move ring "+ n +" from "+ from_peg +" to "+ to_peg);
towerOfHanoi(n-1,aux_peg, to_peg, from_peg);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n= sc.nextInt();
towerOfHanoi(n,'A','B','C');
}
}