// Arup Guha
// 7/14/2026
// Solution to 1994 UCF HSPT Problem: In Line at the Bank

/*** Fixed on 7/15/2026 by consulting the my old solution (which was also buggy, but
     helped me realize the error in this one. My error here was that I was printing
	 the time that people got to see the teller for time in and not the time the
	 got in line, but it's fairly clear that we want to print the time they started
	 waiting, not the time they started their service.
***/

import java.util.*;

public class bank {
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		
		/*** Note: The posted C solution doesn't do what the specification says. The
		           posted C solution places a blank line after the output for every
				   case, including the last one. The specification is clear:
				   "Separate the output from different data sets by two blank lines."
				   So I am just going to keep this in my posted solution. Also,
				   I have posted the output data based on my solution because the C
				   solution posted crashes on my computer. I am sure it was written
				   on a different compiler!
		***/
		
		// This is annoying.
		boolean printBlank = false;
		
		// Process cases.
		while (stdin.hasNext()) {
		
			// To make between cases, two of them.
			if (printBlank) System.out.println("\n");

			// Get # of customers.
			int n = stdin.nextInt();
			
			// This will store the times the tellers are free to help a customer.
			PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
			for (int i=0; i<5; i++) pq.offer(0);
			
			// I just did exact spaces here to mimic what was in the printed description.
			System.out.println("CUSTOMER        TRANSACTION/COMPLETED        IN       OUT");
			for (int i=0; i<58; i++) System.out.print("-");
			System.out.println();
			int curT = 0;
			
			// Process each customer.
			for (int i=0; i<n; i++) {
			
				// This takes a long time to read in...
				String name = stdin.next();
				int addT = stdin.nextInt();
				curT += addT;
				int maxWait = stdin.nextInt();
				String op = stdin.next();
				String amt = "";
				boolean hasNum = op.equals("LOAN") || op.equals("WITHDRAW");
				if (hasNum) amt = stdin.next();
				
				// Get this out of the way.
				if (curT + maxWait < pq.peek()) 
					output(name, op, hasNum, amt, curT, curT+maxWait, "NO");
					
				// A transaction.
				else {
				
					// Next teller ready.
					int next = pq.poll();
					
					// Get how long this will take.
					int tNeed = getTime(op, hasNum, amt);
					
					// Ta da!
					output(name, op, hasNum, amt, curT, Math.max(curT, next)+tNeed, "YES");
					
					// Teller will be ready at this time.
					pq.offer(Math.max(curT, next)+tNeed);
				}
			}
			
			// Now we do this.
			printBlank = true;
		}
	}
	
	public static void output(String name, String op, boolean hasNum, String amt, int start, int end, String status) {
		
		// Print the name and then do the padding.
		System.out.print(name);
		int n = 16 - name.length();
		for (int i=0; i<n; i++) System.out.print(" ");
		
		// This is even more annoying.
		
		// Just the operation.
		int charPrint = op.length();
		System.out.print(op);
		
		// If there's a value.
		if (hasNum) {
			System.out.print(" "+amt);
			charPrint += (amt.length()+1);
		}
		
		// Next the status.
		System.out.print("/"+status);
		charPrint += (status.length()+1);
		
		// Now our spaces.
		n = 29 - charPrint;
		for (int i=0; i<n; i++) System.out.print(" ");
		
		// Spacing for this seems ambiguous at best. Here is my best guess.
		String sTime = ""+start;
		n = 10 - sTime.length();
		System.out.print(start);
		for (int i=0; i<n; i++) System.out.print(" ");
		System.out.println(end);
	}
	
	public static int getTime(String op, boolean hasNum, String amt) {
	
		// Get these cases out of the way.
		if (op.equals("DEPOSIT")) return 5;
		if (op.equals("CASHIERS_CHECK")) return 10;
		if (op.equals("ACCOUNT_BALANCE")) return 2;
		if (op.equals("ATM_CARD")) return 20;
		if (op.equals("OPEN_ACCOUNT")) return 30;

		// Note: The spec doesn't say that it's a maximum of two decimal places,
		//       but I am going to make that assumption so I don't have to deal
		//       with floating point error.
		int units = (int)(Double.parseDouble(amt.substring(1))*100 + 9999.99 +1e-9)/10000;
		
		// Then this one.
		if (op.equals("WITHDRAW"))
			return 7 + units;
			
		// Must be a loan.
		return 50 + 3*units;
	}
}