//去B站搜董晓算法,讲的特别好
#include<iostream>
using namespace std;
const int N=100010;
void hanoi(int n,char a,char b,char c)
{
if(n==1)
printf("%c->%d->%c\n",a,n,c);
else
{
hanoi(n-1,a,c,b);
printf("%c->%d->%c\n",a,n,c);
hanoi(n-1,b,a,c);
}
}
int main()
{int n;
char a,b,c;
cin>>n;
cin>>a>>b>>c;
hanoi(n,a,c,b);
return 0;
}