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