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

print((0 if r//M-l//M>0 else min(i*j%M for i in range(l,r) for j in range(i+1,r+1))))
l,r=list(map(int,input().split()))

print((0 if r-l>671 else min(i*j%2019 for i in range(l,r) for j in range(i+1,r+1))))
M = 2019
l, r = list(map(int, input().split()))
print(
    (
        0
        if r // M - l // M > 0
        else min(i * j % M for i in range(l, r) for j in range(i + 1, r + 1))
    )
)

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

-M = 2019 -        if r // M - l // M > 0 -        else min(i * j % M for i in range(l, r) for j in range(i + 1, r + 1)) +        if r - l > 671 +        else min(i * j % 2019 for i in range(l, r) for j in range(i + 1, r + 1))