Given two numbers A and B. The task is to compute the last digit of the resulting F, where F= B! / A! .

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains two number A and B as input.

**Output:**

For each test case, print last digit of B! / A! (B factorial/ A factorial).

**Constraints:**

1<=T<=100

1<=A<=B<=10^{18}

**Example:**

**Input:**

2

2 4

107 109

**Output:**

2

2

**Explanation:**

```
Input : A = 2, B = 4
Output : 2
Explanation : A! = 2 and B! = 24.
F = 24/2 = 12 --> last digit = 2
```

Author: arun03

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

_Shubham_Jain_06 | 404 |

maggiiiii | 315 |

Savage_19 | 310 |

ritikdagar0203 | 241 |

thanuvinu94 | 233 |

Bishnu Dev Panda | 810 |

_Shubham_Jain_06 | 715 |

okayboss | 652 |

maggiiiii | 598 |

Savage_19 | 576 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.