We define a function over all non-negative integer as follows:
Calculate .
You need to answer queries independently.
The first line contains a single integer ().
Each of the next lines contains two integers and (), representing a query.
Output lines. The -th line contains a single integer, representing the answer to the -th query.
10 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
3 3 4 5 3 4 5 4 5 5
Source: The 2022 ICPC Asia Xi'an Regional Contest Problem E.
Author: MagicSpark.