import java.util.*;



public class banking {
	
	public static void main (String [] args){
		try {
		Scanner sc = new Scanner (System.in);
		String line = null;
		String command []; 
		
		List<String> accounts = new ArrayList<String>();
		Map<String, Double> castky = new TreeMap<String, Double>();
		
		line = sc.nextLine();
		
		while("0".equals(line) == false) {
			int pocetUctu = 0;
			try {
				pocetUctu = Integer.parseInt(line);
			} catch (NumberFormatException e) {
			}
			
			for (int i=0; i < pocetUctu ; i++){
				line = sc.nextLine();
				command = line.split(" ");
				
				accounts.add(command[0]);
				try {
					castky.put(command[0], Double.parseDouble(command[1]));
				} catch (Exception e) {
				}
			}
			
			while (true){
				line = sc.nextLine();
				command = line.split(" ");
				
				if ("end".equals(command[0])) {
					System.out.println("end");
					System.out.println("");
					accounts.clear();
					castky.clear();
					break;
				}
				
				if ("withdraw".equals(command[0])) {
					
					// Existuje ucet
					if (accounts.contains(command[1])) {
						// Je dost penez
						double hodnota = 0;
						try {
							hodnota = Double.parseDouble(command[2]);
						} catch (Exception e) {
						}
						if (hodnota < castky.get(command[1])) {
							castky.put(command[1], castky.get(command[1]) - hodnota);
							System.out.println("withdraw " + command[2] + ": ok");
						}
						// Neni dost penez
						else {
							System.out.println("withdraw " + command[2] + ": insufficient funds");
						}
					// Neexistuje ucet
					} else {
						System.out.println("withdraw " + command[2] + ": no such account");
					}
					
				} else if ("create".equals(command[0])) {
					if (accounts.contains(command[1])) {
						System.out.println("create: already exists");
					} else {
						accounts.add(command[1]);
						castky.put(command[1], new Double(0));
						System.out.println("create: ok");
					}
					
				} else if ("deposit".equals(command[0])) {
					
					// Existuje ucet
					if (accounts.contains(command[1])) {
						// Je dost penez
						double hodnota = 0;
						try {
							hodnota = Double.parseDouble(command[2]);
						} catch (Exception e) {
						}
						
						castky.put(command[1], castky.get(command[1]) + hodnota);
						System.out.println("deposit " + command[2] + ": ok");
					// Neexistuje ucet
					} else {
						System.out.println("deposit " + command[2] + ": no such account");
					}
					
				} else if ("transfer".equals(command[0])) {
					
					// Ucty jsou stejne
					if (command[1].equals(command[2])) {
						System.out.println("transfer " + command[3] + ": same account");
					} else {
						// Existuje ucet
						if (accounts.contains(command[1]) && accounts.contains(command[2])) {
							// Je dost penez
							double hodnota = 0;
							try {
								hodnota = Double.parseDouble(command[3]);
							} catch (Exception e) {
							}
							if (hodnota < castky.get(command[1])) {
								castky.put(command[1], castky.get(command[1]) - hodnota);
								castky.put(command[2], castky.get(command[2]) + hodnota);
								if (command[1].charAt(5) != command[2].charAt(5)) {
									System.out.println("transfer " + command[3] + ": interbank");
								} else {
									System.out.println("transfer " + command[3] + ": ok");
								}
									
							} else {
								System.out.println("transfer " + command[3] + ": insufficient funds");
							}
						// Neexistuje ucet
						} else {
							System.out.println("transfer " + command[3] + ": no such account");
						}
					}
				}
			}
			try {
				line = sc.nextLine();
				line = sc.nextLine();
			} catch (NumberFormatException e) {
			}
		}
		System.out.println("goodbye");
		} catch (Exception e) {
		}
	}
}