ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1797. Summit Online Judge. Version 2

Time limit: 0.5 second
Memory limit: 64 MB
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.

Input

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; lr).

Output

For each test case output the number of ways to choose a correct size of the volume in a separate line.

Sample

inputoutput
1
4 5 7 13
5

Notes

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)