#include <bits/stdc++.h>
using namespace std;

int N;
void recursion(int d, string from, string to, string another){
	if(d==1){
		cout << "Move ring "<< 1 << " from " << from << " to " << to << '\n';
	}else{
		recursion(d-1,from,another,to);
		cout << "Move ring "<< d << " from " << from << " to " << to << '\n';
		recursion(d-1,another,to,from);
	}
}
//Move ring 1 from A to C
int main() {
	while(cin >> N){
		recursion(N,"A","C","B");
		cout << '\n';
	}
}