public static void main(String[] args) throws Throwable {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		init();
		int casos = parseInt(in.readLine().trim());
		in.readLine();
		for(int caso = 0; caso < casos ; caso++){
			numbers = new TreeMap<String, Integer>();
			int cantNumbers = parseInt(in.readLine().trim());
			for (int i = 0; i < cantNumbers; i++) {
				String number = cleanNumber(in.readLine( ).trim());
				if( numbers.containsKey(number) )
					numbers.put(number, numbers.get(number)+1);
				else
					numbers.put(number, 1);
			}
			
			int cant = 0;
			for (String string : numbers.keySet()) {
				if( numbers.get(string) > 1 ){
					cant++;
					String imp = string.substring(0, 3).concat("-").concat(string.substring(3, string.length()));
					sb.append(imp).append(" ").append(numbers.get(string)).append("\n");
				}
			}
			if( cant == 0 ) sb.append("No duplicates.\n");
			
			if( caso < casos-1 ){
				sb.append("\n");
				in.readLine( );
			}
		}
		System.out.print(new String(sb));
	}