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

r = L + min(2019, R - L)

ans = 2019

for i in range(L, r):

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

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

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

MOD = 2019

ans = MOD

R = min(R, L + MOD)

for i in range(L, R):

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

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

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

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

-r = L + min(2019, R - L) -ans = 2019 -for i in range(L, r): -    for j in range(i + 1, r + 1): -        ans = min(ans, (i * j) % 2019) +MOD = 2019 +ans = MOD +R = min(R, L + MOD) +for i in range(L, R): +    for j in range(i + 1, R + 1): +        ans = min(ans, (i * j) % MOD)