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))))
L,R=list(map(int,input().split()))

M=2019;l=L%M;r=R%M

print((0 if l>r or R-L>671 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))
    )
)

L, R = list(map(int, input().split()))
M = 2019
l = L % M
r = R % M
print(
    (
        0
        if l > r or R - L > 671
        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())) +L, R = list(map(int, input().split())) +M = 2019 +l = L % M +r = R % M -        if r - l > 671 -        else min(i * j % 2019 for i in range(l, r) for j in range(i + 1, r + 1)) +        if l > r or R - L > 671 +        else min(i * j % M for i in range(l, r) for j in range(i + 1, r + 1))