QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB
[0]

# 3722. 2017

Statistics

Given a,b,c,d, find out the number of pairs of integers (x,y) where axb,cyd and xy is multiple of 2017.

Input

The input contains zero or more test cases and is terminated by end-of-file.

Each test case contains four integers a,b,c,d.

  • 1ab109,1cd109
  • The number of tests cases does not exceed 104.

Output

For each case, output an integer which denotes the result.

Sample Input

1 2017 1 2016
1 1000000000 1 1000000000

Sample Output

2016
991324197233775