#include <iostream>
#include <cstring>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void tower_of_henoi(int n,char sta,char helper,char targ){
if(n==0){
return;
}
else{
tower_of_henoi(n-1,sta,targ,helper);
cout<<"Moving ring "<<n<<" from "<<sta<<" to "<<targ<<"\n";
tower_of_henoi(n-1,helper,sta,targ);
}
}
int main(){
int n;
cin >> n;
tower_of_henoi(n,'A','B','C');
}