import java.util.Scanner;

class Wallet {
    private double balance;

    public Wallet() {
        this.balance = 0.0;
    }

    public void add(double amount) {
        this.balance += amount;
    }

    public boolean pay(double amount) {
        if (this.balance >= amount) {
            this.balance -= amount;
            return true;
        }
        return false;
    }

    public double getBalance() {
        return this.balance;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();  
        scanner.nextLine(); // consume newline

        Wallet bitcoinWallet = new Wallet();
        Wallet creditCardWallet = new Wallet();
        Wallet paypalWallet = new Wallet();

        for (int i = 0; i < t; i++) {
            String[] transaction = scanner.nextLine().trim().split("\\s+");

            if (transaction.length != 3) {
                System.out.println("Invalid input");
                continue; // don’t stop program
            }

            String walletType = transaction[0].toLowerCase();
            String transactionType = transaction[1].toLowerCase();

            try {
                double amount = Double.parseDouble(transaction[2]);

                if (amount < 0) {
                    System.out.println("-1");
                    continue;
                }

                Wallet wallet = getWallet(walletType, bitcoinWallet, creditCardWallet, paypalWallet);
                if (wallet == null) {
                    System.out.println("Invalid input");
                    continue;
                }

                if (transactionType.equals("add")) {
                    wallet.add(amount);
                } else if (transactionType.equals("pay")) {
                    boolean success = wallet.pay(amount);
                    if (!success) {
                        System.out.println("Insufficient balance");
                    }
                } else {
                    System.out.println("Invalid input");
                }
            } catch (NumberFormatException e) {
                System.out.println("Invalid input");
            }
        }

        // Final balances
        System.out.printf("%.2f%n", bitcoinWallet.getBalance());
        System.out.printf("%.2f%n", creditCardWallet.getBalance());
        System.out.printf("%.2f%n", paypalWallet.getBalance());

        scanner.close();
    }

    public static Wallet getWallet(String walletType, Wallet bitcoinWallet, Wallet creditCardWallet, Wallet paypalWallet) {
        switch (walletType) {
            case "bitcoin":
                return bitcoinWallet;
            case "creditcard":
                return creditCardWallet;
            case "paypal":
                return paypalWallet;
            default:
                return null;
        }
    }
}
