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

a = [False for i in range(2019)]



for i in range(L,min(L+2019,R)+1):

    a[i%2019] = True

ans = 4000

for i in range(2019):

    if not a[i]:

        continue

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

        if not a[j]:

            continue

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

print(ans)

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

ans = 4000



for i in range(L,R+1):

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

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

        if ans == 0:

            break

    else:

        continue

    break

print(ans)

L, R = list(map(int, input().split()))
a = [False for i in range(2019)]
for i in range(L, min(L + 2019, R) + 1):
    a[i % 2019] = True
ans = 4000
for i in range(2019):
    if not a[i]:
        continue
    for j in range(i + 1, 2019):
        if not a[j]:
            continue
        ans = min(ans, i * j % 2019)
print(ans)

L, R = list(map(int, input().split()))
ans = 4000
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        ans = min(ans, i * j % 2019)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

-a = [False for i in range(2019)] -for i in range(L, min(L + 2019, R) + 1): -    a[i % 2019] = True -for i in range(2019): -    if not a[i]: +for i in range(L, R + 1): +    for j in range(i + 1, R + 1): +        ans = min(ans, i * j % 2019) +        if ans == 0: +            break +    else: -    for j in range(i + 1, 2019): -        if not a[j]: -            continue -        ans = min(ans, i * j % 2019) +    break