// Arup Guha
// 10/24/2015
// Solution to 2000 UCF HS Contest Problem: Gotta Fetch 'em All!

import java.util.*;

public class pokeymen {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		// Just need to do this once.
		pokey.fillTables();

		// Process each case.
		while (n != 0) {

			// Read in my pokeys.
			pokey[] mine = new pokey[n];
			for (int i=0; i<n; i++) {
				String name = stdin.next();
				String power = stdin.next();
				int score = stdin.nextInt();
				mine[i] = new pokey(name, power, score);
			}
			boolean[] used = new boolean[n];

			// Header for each case.
			System.out.println("********************\n");

			// Process each battle.
			int battles = stdin.nextInt();
			for (int loop=1; loop<=battles; loop++) {

				// Read in the opponent.
				String power = stdin.next();
				int score = stdin.nextInt();
				pokey opp = new pokey("", power, score);

				// Have no one to face this opponent yet.
				int best = -1, bestdiff = -1000000000;

				// Look for my best.
				for (int i=0; i<n; i++) {
					if (used[i]) continue;

					int res = mine[i].fight(opp);
					//System.out.println(mine[i].name+" "+res);

					// Update if this is a better outcome.
					if (best == -1 || (bestdiff <= 0 && res > bestdiff)
						|| (bestdiff > 0 && res > 0 && res < bestdiff)) {

						best = i;
						bestdiff = res;
					}
				}

				// Match up this opponent.
				used[best] = true;
				System.out.println("Match "+loop+": "+mine[best].name+", I choose you!\n");

			}

			// Get next case.
			n = stdin.nextInt();
		}
	}
}

class pokey {

	final public static String[] POWERS = {"fire","water","earth","air","electricity","poison","psychics","fighting"};
	public static HashMap<String,Integer> map;
	public static ArrayList[] powerList;

	public String name;
	public int power;
	public int score;

	// Stores easy look up table.
	public static void fillTables() {
		map = new HashMap<String,Integer>();
		powerList = new ArrayList[POWERS.length];
		for (int i=0; i<POWERS.length; i++) {
			map.put(POWERS[i], i);
			powerList[i] = new ArrayList<Integer>();
		}
		powerList[0].add(2);
		powerList[1].add(0);
		powerList[2].add(4);
		powerList[3].add(2);
		powerList[4].add(1);
		for (int i=0; i<4; i++) powerList[5].add(i);
		for (int i=0; i<6; i++) powerList[6].add(i);
		powerList[6].add(7);
	}

	public pokey(String n, String p, int s) {
		name = n;
		power = map.get(p);
		score = s;
	}

	public int fight(pokey other) {

		// Standard score.
		int initial = this.score - other.score;

		// See if we need to adjust the score.
		if (powerList[power].contains(other.power)) initial++;
		else if (powerList[other.power].contains(power)) initial--;

		return initial;
	}
}