// Arup Guha
// 10/14/2015
// Solution to 2004 UCF HS Contest Problem: Farm Livin' is the Life for Me

import java.util.*;

class crop {

	final protected int ITEMS_PER_PATCH = 9;

	protected String name;
	protected char ID;
	protected int patches;
	protected int cost;
	protected int price;
	protected int days;

	public crop(String myname, int numpatches, int expense, int profit, int period) {
		name = myname;
		ID = getID();
		patches = numpatches;
		cost = expense;
		price = profit;
		days = period;
	}

	// Finds the letter identifier for this crop (first capital letter).
	public char getID() {
		for (int i=0; i<name.length(); i++)
			if (Character.isUpperCase(name.charAt(i)))
				return name.charAt(i);

		// Should never get here, just to make compiler happy.
		return 'A';
	}

	// Returns true iff dayNumber is a planting day for this crop in a season of length totalDays.
	public boolean plantDay(int dayNumber, int totalDays) {

		// If it's profitable, here's how we check.
		return (dayNumber-1)%days == 0 && dayNumber + days <= totalDays;
	}

	// Returns true iff dayNumber is a harvest day for this crop in a season of length totalDays.
	public boolean harvestDay(int dayNumber, int totalDays) {

		// If it's profitable, here's how we check.
		return (dayNumber-1)%days == 0 && dayNumber > 1;
	}

	public int expenses(int dayNumber, int totalDays) {

		// If we're not planting, there are no expenses.
		if (!plantDay(dayNumber, totalDays)) return 0;

		// Not such a bad calculation...
		return patches*cost;
	}

	public int revenue(int dayNumber, int totalDays) {

		// If we can't harvest, we make no money.
		if (!harvestDay(dayNumber, totalDays)) return 0;

		// This one isn't so bad either.
		return patches*ITEMS_PER_PATCH*price;
	}
}

class multiplecrop extends crop {

	private int regrow;

	public multiplecrop(String myname, int numpatches, int expense, int profit, int period, int repeat) {
		super(myname, numpatches, expense, profit, period);
		regrow = repeat;
	}

	// Returns true iff dayNumber is a planting day for this crop in a season of length totalDays.
	public boolean plantDay(int dayNumber, int totalDays) {

		// Otherwise, just regular procedure.
		return dayNumber == 1 && dayNumber + days <= totalDays;
	}

	// Returns true iff dayNumber is a harvest day for this crop in a season of length totalDays.
	public boolean harvestDay(int dayNumber, int totalDays) {

		// Regular procedure for harvest days.
		return dayNumber >= days+1 && (dayNumber-days-1)%regrow == 0;
	}
}

public class farm {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numDays = stdin.nextInt();
		int loop = 1;

		// Process each case.
		while (numDays != 0) {

			int numCrops = stdin.nextInt();
			crop[] myCrops = new crop[numCrops];

			// Read in each crop.
			for (int i=0; i<numCrops; i++) {

				// Lots of data...
				String name = stdin.next();
				String type = stdin.next();
				int patches = stdin.nextInt();
				int cost = stdin.nextInt();
				int profit = stdin.nextInt();
				int period = stdin.nextInt();

				// This is a regular crop.
				if (type.equals("S")) {
					myCrops[i] = new crop(name, patches, cost, profit, period);
				}

				// This is a multiplecrop.
				else {
					int regrow = stdin.nextInt();
					myCrops[i] = new multiplecrop(name, patches, cost, profit, period, regrow);
				}
			}

			// Our two accumulators and table header.
			int totalCost = 0, totalRevenue = 0;
			printHeader(loop);

			// Simulate each day.
			for (int day=1; day<=numDays; day++) {

				// Nothing to do today.
				if (!active(myCrops, day, numDays)) continue;

				// Go through plantings.
				int curCost = 0;
				String plant = "";
				for (int i=0; i<myCrops.length; i++) {
					if (myCrops[i].plantDay(day, numDays)) {
						plant += myCrops[i].ID;
						curCost += myCrops[i].expenses(day, numDays);
					}
				}

				// Go through harvests.
				int curRevenue = 0;
				String harvest = "";
				for (int i=0; i<myCrops.length; i++) {
					if (myCrops[i].harvestDay(day, numDays)) {
						harvest += myCrops[i].ID;
						curRevenue += myCrops[i].revenue(day, numDays);
					}
				}

				// Update accumuators.
				totalCost += curCost;
				totalRevenue += curRevenue;

				// Line for this day.
				System.out.printf("|%3d|%-10s|%-10s|%7dG|%7dG|\n", day, plant, harvest, curCost, curRevenue);
			}

			// End of chart.
			printTally(totalCost, totalRevenue);
			System.out.println("Ali will make "+(totalRevenue-totalCost)+"G.");
			System.out.println();

			// Get next case.
			numDays = stdin.nextInt();
			loop++;
		}
	}

	public static boolean active(crop[] myCrops, int day, int numDays) {

		// See if any crop is planting or harvesting today.
		for (int i=0; i<myCrops.length; i++) {
			if (myCrops[i].plantDay(day, numDays)) return true;
			if (myCrops[i].harvestDay(day, numDays)) return true;
		}

		// If we get here, nothing is going on today...
		return false;
	}

	public static void printHeader(int loop) {
		System.out.println("Season "+loop);
		System.out.println("+---+----------+----------+--------+--------+");
		System.out.println("|Day|  Plant   | Harvest  |Expenses| Income |");
		System.out.println("+---+----------+----------+--------+--------+");
	}

	public static void printTally(int cost, int revenue) {
		System.out.println("+---+----------+----------+--------+--------+");
		System.out.printf("|ALL|          |          |%7dG|%7dG|\n", cost, revenue);
		System.out.println("+---+----------+----------+--------+--------+");
	}
}