mod = 2019

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

m = min(r, l + mod)

MN=[]

for i in range(l, m):

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

        MN.append(i*j%mod)

print((min(MN)))
mod = 2019

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

m = min(r, l + mod)

MN=[]

for i in range(l, m):

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

        cand = i * j % mod

        if cand:

            MN.append(cand)

        else:

            print((0))

            exit()

print((min(MN)))
mod = 2019
l, r = list(map(int, input().split()))
m = min(r, l + mod)
MN = []
for i in range(l, m):
    for j in range(i + 1, m + 1):
        MN.append(i * j % mod)
print((min(MN)))

mod = 2019
l, r = list(map(int, input().split()))
m = min(r, l + mod)
MN = []
for i in range(l, m):
    for j in range(i + 1, m + 1):
        cand = i * j % mod
        if cand:
            MN.append(cand)
        else:
            print((0))
            exit()
print((min(MN)))

-        MN.append(i * j % mod) +        cand = i * j % mod +        if cand: +            MN.append(cand) +        else: +            print((0)) +            exit()