## COCI '19 Contest 1 #1 Trol

View as PDF

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Stjepan recently received his bachelor's degree in mathematics from the University of Zagreb. Naturally, his parents are very proud and have decided to give him all positive integers not greater than as a gift. To keep them safe, he quickly stored all of those numbers in an array , such that . His jealous friend Marin decided to prank him by repeatedly replacing each element of with the sum of its digits until all elements of consisted of a single digit. For example, the initial value of element of was . Marin first changed that value to and then changed its value again to . Stjepan is devastated and begs Marin to return his array to its initial state. Unfortunately, Marin won't do that until Stjepan correctly answers his queries: "What is the sum of numbers from -th to -th element of ?". Help Stjepan answer those queries!

#### Input

The first line contains an integer () from the task description. The next lines contain two integers and (), the parameters of Marin's -th query.

#### Output

Output the answers to each of Marin's queries. Each answer should be printed in a separate line and their order should match the order of the queries as they are given in the input.

#### Scoring

In test cases worth a total of 20% of the points, for each query will hold.

In test cases worth a total of 60% of the points, for each query will hold.

1
1 5

15

2
9 13
44 45

19
17

.

.

. .

1
1998 2018

102