A printer – who still uses moveable type – is preparing to print a set of pages for a book. These pages are to be numbered, as usual. The printer needs to know how many instances of each decimal digit will be required to set up the page numbers in the section of the book to be printed.

For example, if pages 10, 11, 12, 13, 14 and 15 are to be printed, computing the number of digits is relatively simple: just look at the page numbers that will appear, and count the number of times each digit appears. The digit 0 appears only once, the digit 1 appears 7 times, the digits 2, 3, 4 and 5 each appear once, and 6, 7, 8 and 9 don’t appear at all.

Your task in this problem is to provide the printer with the appropriate counts of the digits. You will be given the numbers of the two pages that identify the section of the book to be printed. You may safely assume that all pages in that section are to be numbered, that no leading zeroes will be printed, that page numbers are positive, and that no page will have more than three digits in its page number.

-----Input-----

There will be multiple cases to consider. The input for each case has two integers, A and B, each of which is guaranteed to be positive. These identify the pages to be printed. That is, each integer P between A and B, including A and B, is to be printed. A single zero will follow the input for the last case.

-----Output-----

For each input case, display the case number (1, 2, …) and the number of occurrences of each decimal digit 0 through 9 in the specified range of page numbers. Display your results in the format shown in the examples below.

-----Example-----
Input:

10 15
912 912
900 999
0

Output:

Case 1: 0:1 1:7 2:1 3:1 4:1 5:1 6:0 7:0 8:0 9:0
Case 2: 0:0 1:1 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:1
Case 3: 0:20 1:20 2:20 3:20 4:20 5:20 6:20 7:20 8:20 9:120

Difficulty: interview

Starter code:

Solutions:
line = input()
test = 0

while line != "0":
    test += 1
    d = {'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
    a = list(map(int,line.split()))
    for i in range(min(a),max(a)+1):
        for c in str(i):
            d[c] += 1
    pairs = list(d.items())
    pairs.sort()        
    print("Case %s: %s" % (test, " ".join(["%s:%s" % (k,v) for k,v in pairs])))
    line = input()

#!/usr/bin/env python

def main():
    t = 1
    while True:
        x = input()
        if x == '0': break
        A, B = list(map(int, x.split()))
        if A > B: A, B = B, A
        x = ''.join(map(str, range(A, B + 1)))
        x = [(k,x.count(str(k))) for k in range(10)]
        print("Case %s: %s" % (t, ' '.join(["%s:%s" % z for z in x])))
        t += 1

main()



entry = input()
t=0
 
while entry != "0":
	
    t+=1
    
    mymap= {
		'0':0,
		'1':0,
		'2':0,
		'3':0,
		'4':0,
		'5':0,
		'6':0,
		'7':0,
		'8':0,
		'9':0
			}
    
    
    n = list(map(int,entry.split()))
    for i in range(min(n),max(n)+1):
        for j in str(i):
            mymap[j] += 1
    store1 = list(mymap.items())
    store1.sort()        
    print("Case %s: %s" % (t, " ".join(["%s:%s" % (k,v) for k,v in store1])))
    entry = input()


line = input()
test = 0
 
while line != "0":
    test += 1
    d = {'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
    a = list(map(int,line.split()))
    for i in range(min(a),max(a)+1):
        for c in str(i):
            d[c] += 1
    pairs = list(d.items())
    pairs.sort()        
    print("Case %s: %s" % (test, " ".join(["%s:%s" % (k,v) for k,v in pairs])))
    line = input()

import sys
def main():
    case=1
    while True:
        try:
            m, n = list(map(int, sys.stdin.readline().split()))
            if m>n:
                m,n=n,m
            r=[str(num) for num in range(m, n+1)]
            s=''.join(r)
            d={}
            for number in s:
                if number not in d:
                    d[number]=1
                else: d[number]+=1
            for q in range(10):
                if str(q) not in d:
                        d[str(q)]=0
            print("Case "+str(case)+": "+"0:"+str(d['0'])+" "+"1:"+str(d['1'])+" "+"2:"+str(d['2'])+" "+"3:"+str(d['3'])+" "+"4:"+str(d['4'])+" "+"5:"+str(d['5'])+" "+"6:"+str(d['6'])+" "+"7:"+str(d['7'])+" "+"8:"+str(d['8'])+" "+"9:"+str(d['9']))
            case+=1
        except:
            break
def __starting_point():
    main()

__starting_point()