P11015 [HackerEarth] pravin saddam and their aptitude question
普及
题目描述

Pravin and Saddam are room-mates.They always solve aptitude questions together. Once, they came across a problem stated as:

"Find the digit at the unit place that appears in sum of factorials of all numbers between A and B (both inclusive)."

Though they are good at mathematics ,but this time they are scratching their heads due to computation of factorials. They seek help from you.
Your job is to help them by writing a code for them to solve their problem.

Input:

First line contains a number T (number of test cases).

Next T lines contains two numbers A and B.

Output:

Print T lines of output where each line contains the required answer.

Constraints:

1 ≤ T ≤ 100

1 ≤ A ≤ B ≤18

SAMPLE INPUT
2
1 2
3 5

SAMPLE OUTPUT
3
0

Explanation

Test case #1:

1! + 2!

=1 + 2=03

unit place =3

Test case#2:

3! + 4! + 5!

= 6 + 24 + 120= 150

unit place =0

输入格式

见题面

输出格式

见题面

样例输入
2 1 2 3 5 SAMPLE
样例输出
3 0