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.

bruceewayne | 119 |

rajupraaa1234 | 110 |

SUZAKU | 104 |

yash_sharan | 104 |

Core_Ka_Bachha | 99 |

mr_kksparrow | 433 |

manvirag982 | 302 |

rajupraaa1234 | 245 |

Exception_404 | 244 |

snow_den_ | 236 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.