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

M=2019;s=list(range(l,r+1))

print((0 if r//M-l//M>0 else min(i*j%M for i in s for j in s if i<j)))
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()))
M = 2019
s = list(range(l, r + 1))
print((0 if r // M - l // M > 0 else min(i * j % M for i in s for j in s if i < j)))

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))
    )
)

+M = 2019 -M = 2019 -s = list(range(l, r + 1)) -print((0 if r // M - l // M > 0 else min(i * j % M for i in s for j in s if i < j))) +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)) +    ) +)