Polycarp is reading a book consisting of nn pages numbered from 11 to nn. Every time he finishes the page with the number divisible by mm, he writes down the last digit of this page number. For example, if n=15n=15 and m=5m=5, pages divisible by mm are 5,10,155,10,15. Their last digits are 5,0,55,0,5 correspondingly, their sum is 1010.
Your task is to calculate the sum of all digits Polycarp has written down.
You have to answer qq independent queries.
Input
The first line of the input contains one integer qq (1≤q≤10001≤q≤1000) — the number of queries.
The following qq lines contain queries, one per line. Each query is given as two integers nn and mm (1≤n,m≤10161≤n,m≤1016) — the number of pages in the book and required divisor, respectively.
Output
For each query print the answer for it — the sum of digits written down by Polycarp.