L, R = list(map(int, input().split()))

target = R+1

if R - L > 10000:

    target = L + 10000

mi = 2019

for i in range(L,target):

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

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

print(mi)
L, R = list(map(int, input().split()))

target = R+1

if R - L > 2019:

    target = L + 2019

mi = 2019

for i in range(L,target):

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

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

print(mi)

L, R = list(map(int, input().split()))
target = R + 1
if R - L > 10000:
    target = L + 10000
mi = 2019
for i in range(L, target):
    for j in range(i + 1, target):
        mi = min(mi, (i * j) % 2019)
print(mi)

L, R = list(map(int, input().split()))
target = R + 1
if R - L > 2019:
    target = L + 2019
mi = 2019
for i in range(L, target):
    for j in range(i + 1, target):
        mi = min(mi, (i * j) % 2019)
print(mi)

-if R - L > 10000: -    target = L + 10000 +if R - L > 2019: +    target = L + 2019