import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Section051 {
	static class member {
		String bu, irum;
		int bon, su;
	}
	public static void main(String[] args) throws IOException {
		Scanner inf = new Scanner(new FileReader("data2.txt"));
		FileWriter ouf = new FileWriter("result2.txt");
		member data = new member();
		int gtot, butot, keb;
		String bubi;
		gtot = 0;
		ouf.write(String.format("\t\t사원 급여표\r\n"));
		ouf.write(String.format("부서\t성명\t본봉\t수당\t합계\r\n"));
		data.bu = inf.next();
		data.irum = inf.next();
		data.bon = inf.nextInt();
		data.su = inf.nextInt();
		while (true)
		{
			butot = 0;
			bubi = data.bu;
			do
			{
				keb = data.bon + data.su;
				butot += keb;
				ouf.write(String.format("%s\t%s\t%d\t%d\t%d\r\n", data.bu, data.irum, data.bon, data.su, keb));
				if (!inf.hasNext())
				{
					gtot += butot;
					ouf.write(String.format("부서 합계 : %d\r\n", butot));
					ouf.write(String.format("전체 합계 : %d", gtot));
					inf.close();
					ouf.close();
					System.exit(0);
				}
				data.bu = inf.next();
				data.irum = inf.next();
				data.bon = inf.nextInt();
				data.su = inf.nextInt();
			} while (bubi.equals(data.bu));
			gtot += butot;
			ouf.write(String.format("부서 합계 : %d\r\n", butot));
		}
	}
}
