#include<iostream>
#include<cmath>
using namespace std;
int a[9], num[9] = { 0 }, ans[9] = { 0 };
int map[9][9];
int cnt = 0;
bool judge(int pos) {
for (int i = 1;i <= 8;i++) {
if (map[pos][i] == 1) {
if (a[i]!=0 && abs(a[pos] - a[i] )== 1)return 0;
}
}
return 1;
}
void dfs(int k) {
if (k == 9) {
cnt++;
for (int i = 1;i <= 8;i++)ans[i] = a[i];
return;
}
if (a[k] != 0)dfs(k + 1);
else{
for (int j = 1;j <= 8;j++) {
if (num[j] == 0) {
a[k] = j;
num[j] = 1;
if (judge(k) == 0) { a[k] = 0;num[j] = 0; }
else { dfs(k+1);a[k] = 0;num[j] = 0;}
}
}
}
}
int main() {
map[1][2] = map[1][3] = map[1][4] = 1;
map[2][3] = map[2][5] = map[2][6] = map[2][1]=1;
map[3][1] = map[3][2] = map[3][4] = map[3][5] = map[3][6] = map[3][7] = 1;
map[4][1] = map[4][3] = map[4][6] = map[4][7]=1;
map[5][2] = map[5][3] = map[5][6] = map[5][8]=1;
map[6][2] = map[6][3] = map[6][4] = map[6][5] = map[6][7] = map[6][8] = 1;
map[7][3] = map[7][4] = map[7][6] = map[7][8] = 1;
map[8][5] = map[8][6] = map[8][7] = 1;
int k,ca=1;
cin >> k;
while (k--) {
memset(num, 0, sizeof(num));
cnt = 0;
for (int i = 1;i <= 8;i++) {
cin >> a[i];
num[a[i]] = 1;
}
dfs(1);
if (cnt == 0)cout << "Case " << ca++ << ": No answer" << endl;
else if (cnt == 1) {
cout << "Case " << ca++ << ": ";
for (int i = 1;i <= 8;i++)cout << ans[i] << " ";
cout << endl;
}
else cout << "Case " << ca++ << ": Not unique" << endl;
}
}