// Arup Guha
// 4/8/2017
// Solution to 2017 Code Jam Qualification Problem D Small: Fashion Show

import java.util.*;

public class d {

	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++) {

			int n = stdin.nextInt();
			int add = stdin.nextInt();
			boolean[] need = new boolean[n];
			Arrays.fill(need, true);
			int x = -1, circle = -1;
			
			// Tracks where there is a circle and diagonal on the first row. If we already have a + we don't need to add
			// one to that spot later.
			for (int i=0; i<add; i++) {
				char c = stdin.next().charAt(0);
				int dummy = stdin.nextInt();
				int col = stdin.nextInt()-1;
				if (c == '+')
					need[col] = false;
				if (c == 'x')
					x = col;
				if (c == 'o')
					circle = col;
			}

			ArrayList<item> list = new ArrayList<item>();
			
			// First go through the first row changes.
			for (int i=0; i<n; i++) {

				// We had a diagonal. I am changing it to a circle.
				if (x == i) {
					list.add(new item(0,i,'o'));
					circle = i;
				}
				
				// We keep this one.
				else if (circle == i) {
					continue;
				}
				
				// If we get to the end and there is no circle or diagonal, I put a circle here.
				else if (i == n-1 && circle == -1 && x == -1) {
					circle = n-1;
					list.add(new item(0,i,'o'));
				}
				
				// In a regular situation where something is needed, I add a +. I am basically loading up +s on my first row.
				else if (need[i]) {
					list.add(new item(0,i,'+'));
				}
			}
			
			// I put these on the backward diagonal also!
			for (int i=1; i<n-1; i++)
				list.add(new item(n-1,i,'+'));

			// add x's
			
			// If there is a circle in column 0, then I go from the bottom to the top of the forward
			// diagonal, skipping the circle and diagonal columns as necessary.
			if (circle == 0) {
				int xRow = n-1;
				for (int i=n-1; i>0; i--) {
					if (i == circle || i == x) continue;
					list.add(new item(xRow,i,'x'));
					xRow--;
				}
			}
			
			// With no circle in slot 0, I can go in my regular order up the backward diagonal skipping the circle and x columns.
			else {

				int xRow = n-1;
				for (int i=0; i<n; i++) {
					if (i == circle || i == x) continue;
					list.add(new item(xRow,i,'x'));
					xRow--;
				}

			}

			// The score is always the same in terms of n...1 is a special case with 1 circle.
			int score = n > 1 ? 3*n-2 : 2;
			System.out.println("Case #"+loop+": "+score+" "+list.size());
			
			// Print it.
			for (int i=0; i<list.size(); i++)
				System.out.println(list.get(i));
		}
	}
}

class item {

	public int r;
	public int c;
	public char ch;

	public item(int myr, int myc, char mych) {
		r = myr;
		c = myc;
		ch = mych;
	}

	public String toString() {
		return ch+" "+(r+1)+" "+(c+1);
	}
}