// Arup Guha
// 10/6/2015
// Solution to 2003 UCF HS Problem: Crosstown Traffic

import java.util.*;

public class traffic {

	final public static int INVALID = -1;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Set up grid - we'll exit on left...
			int lanes = stdin.nextInt();
			int rows = stdin.nextInt();
			int[][] grid = new int[rows][lanes];
			boolean[] letGo = new boolean[100];
			for (int i=0; i<rows; i++)
				for (int j=0; j<lanes; j++)
					grid[i][j] = 10*(j+1) + i+1;

			// Read in car.
			int car = stdin.nextInt();
			car = 10*car + stdin.nextInt();

			// Case header.
			System.out.println("Traffic Jam "+loop+":");

			// Counts the # of cars that go first.
			int ahead = 0;

			// Simulate each step.
			while (grid[0][0] != 0 && grid[0][0] != car) {
				process(grid, letGo);
				ahead++;
			}

			// End of a case.
			System.out.println("Car "+car+" clears the accident.");
			System.out.println("Mike's car will exit after "+ahead+" cars go in front of it.");
			System.out.println();
		}
	}

	// Process one car exiting.
	public static void process(int[][] grid, boolean[] letGo) {

		// Set these up for ease.
		int rows = grid.length;
		int lanes = grid[0].length;

		// First move.
		System.out.println("Car "+grid[0][0]+" clears the accident.");
		grid[0][0] = 0;
		int emptyX = 0, emptyY = 0;

		while (true) {

			// Calculate which cars are where.
			int carBehind = emptyX+1 < rows ? grid[emptyX+1][emptyY] : INVALID;
			int carRight = emptyY+1 < lanes ? grid[emptyX][emptyY+1] : INVALID;

			// No valid cars to move into empty slot, we're good.
			if (carBehind <= 0 && carRight <= 0) break;

			// Slide a car right, unimpeded.
			if (carBehind <= 0) {
				grid[emptyX][emptyY] = grid[emptyX][emptyY+1];
				System.out.println("Car "+grid[emptyX][emptyY]+" moves right.");
				grid[emptyX][emptyY+1] = 0;
				emptyY++;
			}

			// Must move forward.
			else if (carRight <= 0) {
				grid[emptyX][emptyY] = grid[emptyX+1][emptyY];
				System.out.println("Car "+grid[emptyX][emptyY]+" moves forward.");
				grid[emptyX+1][emptyY] = 0;
				emptyX++;
			}

			// We can let someone go!
			else if (!letGo[carBehind]) {
				grid[emptyX][emptyY] = grid[emptyX][emptyY+1];
				System.out.println("Car "+grid[emptyX+1][emptyY]+" lets car "+grid[emptyX][emptyY]+" in.");
				grid[emptyX][emptyY+1] = 0;
				letGo[carBehind] = true;
				emptyY++;
			}

			// We move forward!
			else {
				grid[emptyX][emptyY] = grid[emptyX+1][emptyY];
				System.out.println("Car "+grid[emptyX][emptyY]+" moves forward.");
				grid[emptyX+1][emptyY] = 0;
				emptyX++;
			}
		}
	}
}