1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 340 - Master-Mind Hints
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=276
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.456
*/

import java.io.*;
import java.util.*;
import java.math.*;

class Main {

public static void main(String ...args)
{
Scanner sc = new Scanner(System.in);
int n, strong, weak, gameNumber = 1;
int[] saveOccurences = new int[10];

while(( n = sc.nextInt() ) != 0)
{
int[] s = new int[n];
int[] g = new int[n];
saveOccurences = new int[10];

// read code
for(int i = 0; i < n; i++)
saveOccurences[(s[i] = sc.nextInt())]++;

System.out.println("Game " + gameNumber++ + ":");

while(true)
{
strong = 0;
weak = 0;
int[] occurences = saveOccurences.clone();

// read guess
for(int j = 0; j < n; j++)
g[j] = sc.nextInt();

if(g[0] == 0)
break;


for(int j = 0; j < n; j++)
if(g[j] == s[j])
{
strong++;
occurences[g[j]]--;
g[j] = 0;
}

for(int j = 0; j < n; j++)
if(occurences[g[j]] > 0)
{
weak++;
occurences[g[j]]--;
}

System.out.println(" (" + strong + "," + weak + ")");
}
}
}
}