SP20038 SNGLOOP1 - Easiest Loop 1

Description

Ileana D'Cruz is taking programming classes but she is having problem in understanding **while loops**. She is working on following set of instructions - INTEGER **I = 0, S, U = 10 $ ^{10} $** ; **WHILE** (I < U) **{** S = (3 \* S) + (5 \* I); I = I + 1; **}** Let **S $ _{k} $** be the value assigned to INTEGER **S** for the iteration **I = (k + 1)** and **n, m, p** be positive integers such that **m > n.** Ileana knows the values of **n** and **m** but she forgot the initial value of **S**. She is trying to find the unit digit of **p**. Any initial value of S may be used. She also knows the following equality - **(2 \* n + 3) \* (p - 1) **+** (4 / 5) \* \[(p \* S $ _{n} $ ) - S $ _{m} $ \] **=** 2 \* (m - n)**

Input Format

First line of input is **T**(total no. of test cases). Each of next T lines contains two integers **n** and **m**.

Output Format

Print **unit digit of p (p % 10)** for each test case in separated lines.