L, R = list(map(int, input().split()))



l = L % 2019

r = R % 2019



ans = 2019*2019



if L // 2019 == R // 2019:

    # print(l,r)

    for i in range(l, r):

        # print('i', i)

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

            # print('j', j)



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

else:

    ans = 0



print(ans)

L, R = list(map(int, input().split()))



l = L % 2019

r = R % 2019



ans = 2019*2019



if L // 2019 == R // 2019:

    # print(l,r)

    for i in range(l, r):

        # print('i', i)

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

            # print('j', j)



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

else:

    ans = 0



print(ans)

L, R = list(map(int, input().split()))
l = L % 2019
r = R % 2019
ans = 2019 * 2019
if L // 2019 == R // 2019:
    # print(l,r)
    for i in range(l, r):
        # print('i', i)
        for j in range(l + 1, r + 1):
            # print('j', j)
            ans = min(ans, (i * j) % 2019)
else:
    ans = 0
print(ans)

L, R = list(map(int, input().split()))
l = L % 2019
r = R % 2019
ans = 2019 * 2019
if L // 2019 == R // 2019:
    # print(l,r)
    for i in range(l, r):
        # print('i', i)
        for j in range(i + 1, r + 1):
            # print('j', j)
            ans = min(ans, (i * j) % 2019)
else:
    ans = 0
print(ans)

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