// Arup Guha
// 7/13/2014
// Solution to 2006 UCF HS Problem: Sudokode

import java.util.*;
import java.io.*;

public class sudokode {

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(new File("sudokode.in"));
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in board.
			int[][] board = new int[9][9];
			for (int i=0; i<9; i++)
				board[i] = convert(stdin.next());

			// Solve and print.
			String ans = valid(board) ? "Dave's the man!" : "Try again, Dave!";
			System.out.println("Sudoku #"+loop+":  "+ans+"\n");
		}

		stdin.close();
	}

	// Char to int conversion for string.
	public static int[] convert(String line) {
		int[] ans = new int[9];
		for (int i=0; i<9; i++)
			ans[i] = line.charAt(i) - '0';
		return ans;
	}

	public static boolean valid(int[][] board) {
		return rows(board) && cols(board) && boxes(board);
	}

	public static boolean rows(int[][] board) {

		// Go to each row.
		for (int i=0; i<9; i++) {

			// Count frequencies.
			int[] freq = new int[9];
			for (int j=0; j<9; j++)
				freq[board[i][j]-1]++;

			// See if any are invalid.
			for (int j=0; j<9; j++)
				if (freq[j] != 1)
					return false;
		}

		// Made it.
		return true;
	}

	public static boolean cols(int[][] board) {

		// Go to each column.
		for (int j=0; j<9; j++) {

			// Count frequencies.
			int[] freq = new int[9];
			for (int i=0; i<9; i++)
				freq[board[i][j]-1]++;

			// See if any are invalid.
			for (int i=0; i<9; i++)
				if (freq[i] != 1)
					return false;
		}

		// Made it.
		return true;
	}

	public static boolean boxes(int[][] board) {

		// Go to each row.
		for (int i=0; i<9; i++) {

			// Count frequencies.
			int[] freq = new int[9];
			for (int j=0; j<3; j++)
				for (int k=0; k<3; k++)
					freq[board[3*(i/3)+j][3*(i%3)+k]-1]++;

			// See if any are invalid.
			for (int j=0;j<9; j++)
				if (freq[j] != 1)
					return false;
		}

		// Made it.
		return true;
	}
}