include<iostream>
include<cstring>
using namespace std;
long long a[21][3];
int vist[25];
long long st[22];
int s = 1,p=0,o=1;
void d(long long n,long long s)
{
st[s] = n;
vist[n] = 1;
for (int i = 0; i < 3; i++)
{
if (s == 20 && a[n][i] == st[1])
{
cout << o << ": ";
for (int i = 1; i < 21; i++)
{
cout << " " << st[i];
}
cout <<" " <<st[1]<< endl; o++;
}
if (vist[a[n][i]] != 1)
{
d(a[n][i],s+1);
}
}
vist[n] = 0;
}
int main()
{
for (int i = 1; i <= 20; i++)
cin >> a[i][0] >> a[i][1] >> a[i][2];
long long n;
while (cin >> n && n != 0)
{
memset(vist, 0, sizeof(vist));
d(n,1);
}
}
网友评论