// Arup Guha
// 7/7/2014
// Solution to 2007 UCF HS Contest Problem: The Epic of Aldez: The Mirror of Deceit

// Note: This one problem is why I will never ever forget Nick Beato, who excelled at
//       saying in 1000 words what could have been said in 10. (He made the problem.)

import java.util.*;
import java.io.*;

public class epic {

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(new File("epic.in"));
		int loop = 1;

		// Go through each case.
		while (true) {

			// Read in dimensions & print case header.
			int dummy = stdin.nextInt();
			int rows = stdin.nextInt();
			if (rows == 0) break;

			// Print case header.
			System.out.println("Dungeon "+loop+":");

			// Process each row.
			for (int i=0; i<rows; i++) {

				// Read and print backwards.
				char[] line = stdin.next().toCharArray();
				for (int j=line.length-1; j>=0; j--)
					System.out.print(line[j]);
				System.out.println();
			}

			// Go to next case.
			System.out.println();
			loop++;
		}

		// Close file.
		stdin.close();
	}
}