The program committee of Yekaterinozavodsk programming contests decided to create a new website. In honor of the recent summit of the Harbin Cooperation Organization, they decided to name this website Summit Online Judge.
The website will contain a problem archive, which will be regularly extended with problems from contests held at this website. According to the current rules, the problem set of any contest must contain x or y problems.
The contests at the Summit Online Judge will be held often enough, which means
that the number of problems in the archive will increase fast. For convenience, it
was decided to divide the archive into volumes of equal size. The size of the volume is called correct if there is at least one way to hold several contests so that the total number of problems in these contests would be equal to the size of the volume. In addition, the size must be in the range from l to r.
Your task is to find the number of ways to choose a correct size of the volume.
The first line contains the number of test cases (not more than 100).
Each of the following lines contains four space-separated integers x, y, l, r (1 ≤ x, y, l, r ≤ 1018; l ≤ r).
For each test case output the number of ways to choose a correct size of the volume in a separate line.
In the example above, the size of the volume can be equal to 8, 9, 10, 12, or 13.
This problem is the same as “Summit Online Judge
” but with another problem set size conditions and input format.
Problem Author: Xie Lingxi (original problem by Alex Samsonov)