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

public class Section050 {
	static final int LENGTH = 10;
	static class member {
		String n;
		int p;
		int pm[] = new int[10];
	}
	
	public static void main(String[] args) throws IOException{
		Scanner inf = new Scanner(new FileReader("data.txt"));
		member data = new member();
		int tm[] = new int[10];
		int k, t, m, sw;
		System.out.printf("\t\t\t\t출장비 지급표\n");
		System.out.printf("성명 출장비지급액      오만      일만      오천     일천      오백     일백      오십      일십       오         일\n");
		for (k = 0; k <= LENGTH - 1; k++)
			tm[k] = data.pm[k] = 0;
		data.n = inf.next();
		data.p = inf.nextInt();
		while (true)
		{
			t = data.p;
			m = 50000;
			sw = 1;
			for (k = 0; k <= LENGTH - 1; k++)
			{
				data.pm[k] = t / m;
				t -= data.pm[k] * m;
				if (sw == 1)
				{
					m /= 5;
					sw = 0;
				}
				else
				{
					m /= 2;
					sw = 1;
				}
			}
			System.out.printf("%s %d", data.n, data.p);
			for (k = 0; k <= LENGTH - 1; k++)
			{
				System.out.printf("%5d", data.pm[k]);
				tm[k] += data.pm[k];
			}
			System.out.printf("\n");
			data.n = inf.next();
			if(data.n.equals("quit")) break;
			data.p = inf.nextInt();
		}
		System.out.printf("전체 화폐 매수        ");
		for (k = 0; k <= LENGTH - 1; k++)
			System.out.printf("%5d", tm[k]);
		inf.close();
	}
}
