SP8177 JZPEXT - Beautiful numbers EXTREME

Description

We call one integer beautiful, if and only if it is divisible by each of its non-zero digits. Given an interval \[l, r\], calculate how many beautiful numbers n satisfy l

Input Format

Then t lines follow, each line two numbers l, r, representing the query interval \[l, r\]

Output Format

t lines. The t-th line is the answer to the t-th query.