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

if r - l >= 2018:

    print((0))

    exit()

l %= 2019

r %= 2019



m=10000

for i in range(l,r):

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

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



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

if r - l >= 2018:

    print((0))

    exit()



m=10000

for i in range(l,r):

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

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



print(m)
l, r = list(map(int, input().split()))
if r - l >= 2018:
    print((0))
    exit()
l %= 2019
r %= 2019
m = 10000
for i in range(l, r):
    for j in range(i + 1, r + 1):
        m = min(m, (i * j) % 2019)
print(m)

l, r = list(map(int, input().split()))
if r - l >= 2018:
    print((0))
    exit()
m = 10000
for i in range(l, r):
    for j in range(i + 1, r + 1):
        m = min(m, (i * j) % 2019)
print(m)

-l %= 2019 -r %= 2019