l,r=list(map(int,input().split()))

a=0

if r-l<2019:

 	a=min([(i%2019*j%2019) for i in range(l,r+1) for j in range(i+1,r+1)])

print((a%2019))
l,r=list(map(int,input().split()))

a=0

if r-l<2019:

 	a=min([(i*j)%2019 for i in range(l,r+1) for j in range(i+1,r+1)])

print(a)
l, r = list(map(int, input().split()))
a = 0
if r - l < 2019:
    a = min(
        [(i % 2019 * j % 2019) for i in range(l, r + 1) for j in range(i + 1, r + 1)]
    )
print((a % 2019))

l, r = list(map(int, input().split()))
a = 0
if r - l < 2019:
    a = min([(i * j) % 2019 for i in range(l, r + 1) for j in range(i + 1, r + 1)])
print(a)

-    a = min( -        [(i % 2019 * j % 2019) for i in range(l, r + 1) for j in range(i + 1, r + 1)] -    ) -print((a % 2019)) +    a = min([(i * j) % 2019 for i in range(l, r + 1) for j in range(i + 1, r + 1)]) +print(a)