// Arup Guha
// 10/10/2013
// Solution to 2012 UCF SH Contest Question: Aquarium

import java.util.*;
import java.io.*;

public class aquarium {

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(new File("aquarium.in"));
		int numCases = stdin.nextInt();

		// Go through each aquarium.
		for (int loop=1; loop<=numCases; loop++) {

			// Get fish parameters.
			int numR = stdin.nextInt();
			int numC = stdin.nextInt();
			int numFish = stdin.nextInt();
			int steps = stdin.nextInt();

			// Get grid.
			char[][] grid = new char[numR][];
			for (int i=0; i<numR; i++)
				grid[i] = stdin.next().toCharArray();

			// Read in fish.
			fish[] minnows = new fish[numFish];
			for (int i=0; i<numFish; i++) {
				String name = stdin.next();
				int size = stdin.nextInt();
				int x = stdin.nextInt();
				int y = stdin.nextInt();
				String seq = stdin.next();

				// Set up object - change to 0-based.
				minnows[i] = new fish(x-1, y-1, size, name, seq);
			}

			// Run our simulation.
			for (int i=0; i<steps; i++) {

				// Move each fish.
				for (int j=0; j<numFish; j++)
					minnows[j].move(grid, i);

				// Calculate who eats who!
				reduce(minnows);
			}

			// Print output.
			System.out.println("Aquarium #"+loop+":");
			print(minnows);
		}
	}

	public static void print(fish[] minnows) {

		// Go through the fish...
		for (int i=0; i<minnows.length; i++) {

			System.out.print((i+1)+". ");

			// Dead case.
			if (!minnows[i].alive)
				System.out.print("(Deceased) ");

			// For each kill!
			for (int j=0; j<minnows[i].curSize-minnows[i].startSize; j++)
				System.out.print("Big ");
			System.out.println(minnows[i].name);
		}
		System.out.println();
	}

	// Post-process a time step.
	public static void reduce(fish[] minnows) {

		int n = minnows.length;
		boolean[] processed = new boolean[n];

		// Process each fish!
		for (int i=0; i<n; i++) {

			// We did this one before.
			if (processed[i] || !minnows[i].alive) continue;

			// Mark this so we don't forget!
			processed[i] = true;

			// Go through the rest of the fish.
			ArrayList<fish> sameSpot = new ArrayList<fish>();
			sameSpot.add(minnows[i]);
			for (int j=i+1; j<n; j++) {

				// Add this to our list to consider and mark it as processed.
				if (minnows[i].samePlace(minnows[j]) && minnows[j].alive) {
					sameSpot.add(minnows[j]);
					processed[j] = true;
				}
			}

			// Sort these - the best will win this spot and grow by the size of the rest.
			Collections.sort(sameSpot);
			int numF = sameSpot.size();

			// Kill off the rest.
			for (int j=0; j<numF-1; j++) {
				if (sameSpot.get(j).alive) sameSpot.get(numF-1).curSize++;
				sameSpot.get(j).alive = false;
			}
		}
	}
}

class fish implements Comparable<fish> {

	// Directional movement constants.
	public final static int STATIONARY = 0;
	public final static int UP = 1;
	public final static int LEFT = 2;
	public final static int RIGHT = 3;
	public final static int DOWN = 4;

	// Parts of the object.
	public int x;
	public int y;
	public int startSize;
	public int curSize;
	public String name;
	public String moves;
	public boolean alive;
	public int lastMove;

	public fish(int r, int c, int size, String myName, String myMoves) {
		x = r;
		y = c;
		startSize = size;
		curSize = size;
		name = myName;
		moves = myMoves;
		alive = true;
	}

	// Move this fish in grid for the time step step.
	public void move(char[][] grid, int step) {

		if (!alive) return;

		// Get move;
		char move = moves.charAt(step%moves.length());

		// Set up directional move.
		int dx = 0, dy = 0;
		if (move == 'U') dx--;
		else if (move == 'D') dx++;
		else if (move == 'L') dy--;
		else dy++;

		// Can't move off grid.
		if (x+dx < 0 || x+dx >= grid.length || y+dy  < 0 || y+dy >= grid[0].length) {
			lastMove = STATIONARY;
			return;
		}

		// Can't move onto coral.
		if (grid[x+dx][y+dy] == 'X')  {
			lastMove = STATIONARY;
			return;
		}

		// Move
		x += dx;
		y += dy;

		// Mark the last move for comparison purposes.
		if (dx == 1) lastMove = DOWN;
		if (dy == 1) lastMove = RIGHT;
		if (dy == -1) lastMove = LEFT;
		if (dx == -1) lastMove = UP;
	}

	// Compare to fish to see who will eat who!
	public int compareTo(fish other) {

		// Easy cases.
		if (this.curSize != other.curSize)
			return this.curSize - other.curSize;

		// We break ties by direction.
		return this.lastMove - other.lastMove;
	}

	public boolean samePlace(fish other) {
		return this.x == other.x && this.y == other.y;
	}
}