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

LR = list(range(L,R+1))

from itertools import permutations, combinations,combinations_with_replacement,product

if (R+1-L)<2019:

  C = combinations(LR, 2)

  Ret = 2019

  for i in list(C):

    Ret = min(Ret,(i[0]*i[1])%2019)

else:

  Ret = 0

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

from itertools import permutations, combinations,combinations_with_replacement,product

if (R+1-L)<2019:

  LR = list(range(L,R+1))

  LRA = []

  for i in LR:

    LRA.append(i%2019)

  LRAA = set(LRA)

  C = combinations(LRAA, 2)

  Ret = 2019

  for i in list(C):

    Ret = min(Ret,(i[0]*i[1])%2019)

else:

  Ret = 0

print(Ret)

L, R = list(map(int, input().split()))
LR = list(range(L, R + 1))
from itertools import permutations, combinations, combinations_with_replacement, product

if (R + 1 - L) < 2019:
    C = combinations(LR, 2)
    Ret = 2019
    for i in list(C):
        Ret = min(Ret, (i[0] * i[1]) % 2019)
else:
    Ret = 0
print(Ret)

L, R = list(map(int, input().split()))
from itertools import permutations, combinations, combinations_with_replacement, product

if (R + 1 - L) < 2019:
    LR = list(range(L, R + 1))
    LRA = []
    for i in LR:
        LRA.append(i % 2019)
    LRAA = set(LRA)
    C = combinations(LRAA, 2)
    Ret = 2019
    for i in list(C):
        Ret = min(Ret, (i[0] * i[1]) % 2019)
else:
    Ret = 0
print(Ret)

-LR = list(range(L, R + 1)) -    C = combinations(LR, 2) +    LR = list(range(L, R + 1)) +    LRA = [] +    for i in LR: +        LRA.append(i % 2019) +    LRAA = set(LRA) +    C = combinations(LRAA, 2)