/*
UVA 340 - Master-Mind Hints
游戏:给出一串长度为n数字,猜这串数字,每次反馈回数字且位置对的个数a,数字对位置不对的个数b,每次返回(a,b).
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int num[1005],ans[1005];
int cntn[15],cnta[15],cnt[15];
int main(){
int n,i,t = 1;
while(cin >> n && n){
cout <<"Game " <<t++ <<":" <<endl;
memset(cnt,0,sizeof(cnt));
for(i = 0;i < n;i++){
cin >>num[i];
cnt[num[i]]++; //记录要猜的数字串中各个数字的数量
}
while(1){
int a = 0,b = 0;
memset(cnta,0,sizeof(cnta));
memcpy(cntn,cnt,sizeof(cntn)); //注意:如果没有这一步,之前的操作会影响数字正确但位置不对时的统计
for(i = 0;i < n;i++){
cin >>ans[i];
cnta[ans[i]]++;
}
if(!ans[0]) break;
for(i = 0;i < n;i++){
if(num[i] == ans[i]){
a++;
cnta[ans[i]]--;
cntn[num[i]]--; //若数字且位置相同,a++,在统计的个数中减一
}
}
for(i = 1;i < 10;i++){
b += (cntn[i] >= cnta[i])?cnta[i]:cntn[i]; //统计位置不正确的数字
}
cout <<" (" <<a <<"," <<b <<")"<<endl;
}
}
return 0;
}