import java.util.Hashtable;

public class banking {
	
	public static String nactiRadku(int maximalniDelka){
		byte pole[] = new byte[maximalniDelka];
		int pozice =  0;
		int znak = -1;
		try{
			while (pozice < maximalniDelka){
				znak = System.in.read();
				if((znak<0) || (znak == '\n')) {
					break;
				}
				pole[pozice] += znak;
				pozice++;
			}
		} catch (Exception e){
			return null;
		}
		if ((znak < 0) && (pozice == 0)){
			return null;
		}
		return (new String(pole,0,pozice));
	}
		
		
		
	
	
	public static void main(String[] args) {
		try {
		while(process()>0)
			;
		}catch(NumberFormatException e) {}
		syso("goodbye");
	}
	
	/**
	zpracuje jeden pripad
	*/
	public static int process() {
		String end = "end";
		int a = Integer.parseInt(nactiRadku(10).trim());
		if(a==0) {
			return(0);
		}
		Hashtable<String, Integer> accounts = new Hashtable<String, Integer>();
		for(int i=0; i<a; i++) {
			String[] x = nactiRadku(35).split(" ");
			accounts.put(x[0], new Integer(x[1].replace(".", "").replace(",", "")));
		}
		while(true) {
			String x = nactiRadku(35).trim();
			if(x.equals(end)) {
				nactiRadku(10);
				break;
			} else if(x.length()==0) {
				break;
			}
			String[] xx = x.split(" ");
			if(xx[0].equals("create")) {
				Integer amount = accounts.get(xx[1]);
				if(amount == null) {
					accounts.put(xx[1], new Integer(0));
					syso("create: ok");
				} else {
					syso("create: already exists");
				}
			} else if(xx[0].equals("deposit")) {
				Integer amount = accounts.get(xx[1]);
				if(amount == null) {
					syso("deposit "+xx[2]+": no such account");
				} else {
					Integer dep = new Integer(xx[2].replace(".", "").replace(",", ""));
					accounts.put(xx[1], new Integer(amount.intValue()+dep.intValue()));
					syso("deposit "+xx[2]+": ok");
				}
			} else if(xx[0].equals("withdraw")) {
				Integer amount = accounts.get(xx[1]);
				if(amount == null) {
					syso("withdraw "+xx[2]+": no such account");
				} else {
					Integer dep = new Integer(xx[2].replace(".", "").replace(",", ""));
					if(dep.intValue()>amount.intValue()) {
						syso("withdraw "+xx[2]+": insufficient funds");
					} else {
						accounts.put(xx[1], new Integer(amount.intValue()-dep.intValue()));
						syso("withdraw "+xx[2]+": ok");
					}
				}
			} else if(xx[0].equals("transfer")) {
				Integer from = accounts.get(xx[1]);
				Integer to = accounts.get(xx[2]);
				if(from == null || to == null) {
					syso("transfer "+xx[3]+": no such account");
				} else {
					int amount = Integer.parseInt(xx[3].replace(".", "").replace(",", ""));
					if(xx[1].equals(xx[2])) {
						syso("transfer "+xx[3]+": same account");
					} else if(from.intValue()<amount) {
						syso("transfer "+xx[3]+": insufficient funds");
					} else {
						accounts.put(xx[1], new Integer(from.intValue()-amount));
						accounts.put(xx[2], new Integer(to.intValue()+amount));
						if(xx[1].charAt(5)==xx[2].charAt(5)) {
							syso("transfer "+xx[3]+": ok");
						} else {
							syso("transfer "+xx[3]+": interbank");
						}
					}
				}
			}
		}
		syso("end");
		syso("");
		return(a);
	}
	
	public static void syso(String value) {
		System.out.println(value);
	}
}
