#include <stdio.h>
int visited[8];
int graph[8][8];
void DFS(int index)
{
printf("%d,", index + 1);
visited[index] = 1;
for (int i = 0; i < 8; i++)
{
if (graph[index][i] != 0&&visited[i]!=1)
{
DFS(i);
}
}
}
int main()
{
int need;
scanf("%d", &need);
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
graph[i][j] = 0;
}
}
graph[0][1] = 1;
graph[1][0] = 1;
graph[0][2] = 1;
graph[2][0] = 1;
graph[1][3] = 1;
graph[3][1] = 1;
graph[1][4] = 1;
graph[4][1] = 1;
graph[2][5] = 1;
graph[5][2] = 1;
graph[2][6] = 1;
graph[6][2] = 1;
graph[3][7] = 1;
graph[7][3] = 1;
graph[4][7] = 1;
graph[7][4] = 1;
graph[5][7] = 1;
graph[7][5] = 1;
graph[6][7] = 1;
graph[7][6] = 1;
for (int i = 0; i < 8; i++)
{
visited[i] = 0;
}
DFS(need - 1);
return 0;
}