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

mod = 2019

s = 2018

for i in range(L, min(R, L+2018)):

    for j in range(i+1, min(R+1, L+2019)):

        t = (i%mod)*(j%mod)%mod

        if s > t:

            s = t

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

mod = 2019

s = 2018

for i in range(L,R):

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

        t = (i%mod)*(j%mod)%mod

        if s > t:

            s = t

        if t == 0:

            break

    else:

        continue

    break

print (s)
L, R = list(map(int, input().split()))
mod = 2019
s = 2018
for i in range(L, min(R, L + 2018)):
    for j in range(i + 1, min(R + 1, L + 2019)):
        t = (i % mod) * (j % mod) % mod
        if s > t:
            s = t
print(s)

L, R = list(map(int, input().split()))
mod = 2019
s = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        t = (i % mod) * (j % mod) % mod
        if s > t:
            s = t
        if t == 0:
            break
    else:
        continue
    break
print(s)

-for i in range(L, min(R, L + 2018)): -    for j in range(i + 1, min(R + 1, L + 2019)): +for i in range(L, R): +    for j in range(i + 1, R + 1): +        if t == 0: +            break +    else: +        continue +    break