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

if r>l+4040:

    r=l+4040

dif=r-l

minimum=1000000000

for i in range(l%2019,l%2019 + dif+1):

    for j in range(i+1,l%2019 +dif +1):

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

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

minimum=1000000000

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

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

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

        if minimum==0:

            break

    if minimum ==0:

        break

print(minimum)
l, r = list(map(int, input().split()))
if r > l + 4040:
    r = l + 4040
dif = r - l
minimum = 1000000000
for i in range(l % 2019, l % 2019 + dif + 1):
    for j in range(i + 1, l % 2019 + dif + 1):
        minimum = min(minimum, ((i * j) % 2019))
print(minimum)

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

-if r > l + 4040: -    r = l + 4040 -dif = r - l -for i in range(l % 2019, l % 2019 + dif + 1): -    for j in range(i + 1, l % 2019 + dif + 1): +for i in range(l, r + 1): +    for j in range(i + 1, r + 1): +        if minimum == 0: +            break +    if minimum == 0: +        break