// Arup Guha
// 2/22/2013
// Solution to 2011 South East Regional Problem F: Folding

import java.util.*;

public class f {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int width, height, numFolds;

		width = stdin.nextInt();
		height = stdin.nextInt();
		numFolds = stdin.nextInt();

		while (width != 0) {

			fold[] myFolds = new fold[numFolds];

			// Read in folds...
			for (int i=0; i<numFolds; i++) {
				String s = stdin.next();
				int num = stdin.nextInt();
				myFolds[i] = new fold(s, num);
			}

			point[] dim = new point[numFolds+1];
			int endWidth = width;
			int endHeight = height;
			dim[0] = new point(width, height);

			// Store dimensions of each sub-board, by folding forward.
			for (int i=0; i<numFolds; i++) {
				if (myFolds[i].dir == 'L' || myFolds[i].dir == 'R')
					endWidth = Math.max(endWidth-myFolds[i].dist, myFolds[i].dist);
				else
					endHeight = Math.max(endHeight-myFolds[i].dist, myFolds[i].dist);
				dim[i+1] = new point(endWidth, endHeight);
			}

			// Storage for the maximum number of points.
			int numPts = 1;
			point[] allPts = new point[1 << numFolds];

			// Seed the first point.
			int x = stdin.nextInt();
			int y = stdin.nextInt();
			allPts[0] = new point(x, y);

			// Manually undo all folds.
			for (int i=numFolds-1; i>=0; i--)
				numPts = undo(i, allPts, numPts, myFolds[i], dim);

			// Output the answer.
			System.out.println(numPts);

			// Go to the next case.
			width = stdin.nextInt();
			height = stdin.nextInt();
			numFolds = stdin.nextInt();
		}

	}

	// Unfolds the level fold, with allPts[0..numPts-1] storing the current points, with thisFold
	// and dim storing the dimensions of each "paper", so to speak.
	public static int undo(int level, point[] allPts, int numPts, fold thisFold, point[] dim) {

		int curIndex = numPts;

		// Current dimensions.
		int width = dim[level+1].x;
		int height = dim[level+1].y;

		// Perform a right unfold.
		if (thisFold.dir == 'R') {

			// Go through each point.
			for (int i=0; i<numPts; i++) {

				int diff = width - allPts[i].x;
				int widthLeft = dim[level].x - thisFold.dist;

				// The point is on both sides of the paper, so a new point will be added.
				if (diff < thisFold.dist && diff < dim[level].x - thisFold.dist) {
					allPts[curIndex] = new point(widthLeft+diff, allPts[i].y);
					curIndex++;

					// Fix old point, since the origin-x changed.
					if (thisFold.dist == width)
						allPts[i].x -= (2*thisFold.dist - dim[level].x);
				}

				// No new point, but the x value of this moved, since the paper moved.
				else if (diff < thisFold.dist)
					allPts[i].x = dim[level].x - allPts[i].x;

			}

		}

		// Undo top move.
		else if (thisFold.dir == 'T') {

			// Go through each point.
			for (int i=0; i<numPts; i++) {

				int diff = height - allPts[i].y;
				int heightLeft = dim[level].y - thisFold.dist;

				// The points is on both sides of the paper, so a new point will be added.
				if (diff < thisFold.dist && diff < dim[level].y - thisFold.dist) {
					allPts[curIndex] = new point(allPts[i].x, heightLeft+diff);
					curIndex++;

					// Fix the old point, since the origin-y changed.
					if (thisFold.dist == height)
						allPts[i].y -= (2*thisFold.dist - dim[level].y);
				}

				// No new point, but hte y value of this moved.
				else if (diff < thisFold.dist)
					allPts[i].y = dim[level].y - allPts[i].y;
			}

		}

		// Perform left unfold.
		else if (thisFold.dir == 'L') {

			// Go through each point.
			for (int i=0; i<numPts; i++) {

				int diff = allPts[i].x;

				// The point is on both sides of the paper.
				if (diff < thisFold.dist && diff < dim[level].x - thisFold.dist) {
					allPts[curIndex] = new point(-diff, allPts[i].y);
					curIndex++;
				}

				// No new point, but flip this point over the fold.
				else if (diff < thisFold.dist)
					allPts[i].x = -diff;

			}

			// Edit all points for the new x-values.
			for (int i=0; i<curIndex; i++)
				allPts[i].x += thisFold.dist;
		}

		// Perform bottom unfold.
		else {

			// Go through each point.
			for (int i=0; i<numPts; i++) {

				int diff = allPts[i].y;

				// This point is on both sides of the paper.
				if (diff < thisFold.dist && diff < dim[level].y - thisFold.dist) {
					allPts[curIndex] = new point(allPts[i].x, -diff);
					curIndex++;
				}

				// No new point, but flip this point over the fold.
				else if (diff < thisFold.dist)
					allPts[i].y = -diff;
			}

			// Edit all points with their new y value.
			for (int i=0; i<curIndex; i++)
				allPts[i].y += thisFold.dist;

		}

		return curIndex;
	}

}

class fold {

	public char dir;
	public int dist;

	public fold(String s, int a) {
		dir = s.charAt(0);
		dist = a;
	}
}

class point {

	public int x;
	public int y;

	public point(int myx, int myy) {
		x = myx;
		y = myy;
	}
}