Limits 1s, 512 MB

Today is your best friend SJ’s birthday. You want to buy a birthday present for her. You want to buy such a present that she likes the most. You are very superstitious. You think that, SJ will love your gift, if the price of the present you buy is an interesting number (pretty weird isn’t it 😛).

Interesting numbers are:

  1. A number of the format xyx^y. Where x2x \ge 2 and y2y \ge 2. For example, 4=224 = 2^2, 8=238 = 2^3, 9=329 = 3^2 etc. are interesting numbers. Here xx and yy are integers.
  2. Summation of two or more interesting numbers is also an interesting number. For example 13=9+413 = 9 + 4, 17=9+4+417 = 9 + 4 + 4 etc. are interesting numbers.

Input

The first line of the input is an integer tt (1t1051 ≤ t ≤ 10^5) denoting the number of test cases. Then tt line follows. Each line has two integers aa and bb (1ab10181 ≤ a ≤ b ≤ 10^{18}).

Output

For each case you have to print a single line denoting the number of interesting numbers between aa and bb (inclusive).

Sample

InputOutput
3
1 4
7 10
15 20
1
2
4

Submit

Login to submit.

Statistics

89% Solution Ratio
R1shadEarliest, Aug '15
Asif_AlimFastest, 0.0s
PKP007Lightest, 131 kB
mdvirusShortest, 167B
Toph uses cookies. By continuing you agree to our Cookie Policy.