atcoder#ARC112A. [ARC112A] B = C

[ARC112A] B = C

Score : 300300 points

Problem Statement

How many triples A,B,CA,B,C of integers between LL and RR (inclusive) satisfy AB=CA-B=C?

You will be given TT cases. Solve each of them.

Constraints

  • 1T2×1041 \leq T \leq 2\times 10^4
  • 0LR1060\le L \le R \le 10^6
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

TT

case1\text{case}_1

\vdots

caseT\text{case}_T

Each case is in the following format:

LL RR

Output

Print TT values; the ii-th of them should be the answer for casei\text{case}_i.

5
2 6
0 0
1000000 1000000
12345 67890
0 1000000
6
1
0
933184801
500001500001

In the first case, we have the following six triples:

  • 42=24 - 2 = 2
  • 52=35 - 2 = 3
  • 53=25 - 3 = 2
  • 62=46 - 2 = 4
  • 63=36 - 3 = 3
  • 64=26 - 4 = 2