#include<iostream>
#include<algorithm>
using namespace std;
int n;
char a,b,c;
void move(char a,char b,int n)
{
printf("%c->%d->%c\n",a,n,b);
}
void hanoi(int n,char a,char b,char c)
{
if(n > 0)
{
hanoi(n-1,a,c,b);
move(a,b,n);
hanoi(n-1,c,b,a);
}
}
int main()
{
cin >>n;
cin >>a>>b>>c;
hanoi(n,a,b,c);
return 0;
}