## DMOPC '15 Contest 4 P5 - Scribe

View as PDF

Points: 15 (partial)
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type

Library and Archives Canada has decided to archive all English essays from Canadian high schools so that they may be preserved for future generations to study, and Brian Kernighan (of K&R C fame) has been hired to manually type up the page numbers in the margin of every page. Since his keyboard's numpad has a limited number of key presses before the buttons break, he'd like to know if he'll be able to type up all essays without breaking his keyboard (or determine that he'll have to order a new computer with a sturdier keyboard).

Kernighan has been given essays, where essay should be numbered from to inclusive. For each essay, he'd like to know how many times each integer appears in the page number range. So that you don't lose this once-in-a-lifetime chance of talking with a legend, you've decided to write a program to answer his queries and impress him!

#### Input Specification

The first line of the input will contain the integer .
For the next lines of input, line will contain two space-separated integers and .

#### Output Specification

For each essay, output integers on a line, separated by a single space. Integer will contain the number of times the digit appears in the essay's page range.

#### Sample Input

10
1 10
346 542
1199 1748
1403 1496
503 1004
190 1714
854 1317
494 1976
1001 1960
44 497

#### Sample Output

1 2 1 1 1 1 1 1 1 1
40 40 40 93 136 82 40 40 40 40
115 666 215 215 214 205 205 154 105 106
16 113 19 20 114 20 20 19 19 16
107 105 100 101 101 197 200 200 200 200
413 1133 503 503 503 502 502 417 402 412
196 512 186 104 87 93 97 97 142 196
398 1375 398 398 405 499 499 495 488 471
294 1256 296 296 296 296 287 286 286 247
85 185 185 185 190 96 96 96 95 93