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

ans = 2019

for i in range(l,min(l+2019,r)):

    for j in range(l+1,min(l+2019,r+1)):

        ans = min(ans,i*j%2019)

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

r = min(r,l+2019)

ans = 2019

for i in range(l,r+1):

    for j in range(i+1,r+1):

        ans = min(ans,i*j%2019)

print(ans)
l, r = list(map(int, input().split()))
ans = 2019
for i in range(l, min(l + 2019, r)):
    for j in range(l + 1, min(l + 2019, r + 1)):
        ans = min(ans, i * j % 2019)
print(ans)

l, r = list(map(int, input().split()))
r = min(r, l + 2019)
ans = 2019
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        ans = min(ans, i * j % 2019)
print(ans)

+r = min(r, l + 2019) -for i in range(l, min(l + 2019, r)): -    for j in range(l + 1, min(l + 2019, r + 1)): +for i in range(l, r + 1): +    for j in range(i + 1, r + 1):