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

if r-l+1>2019:

  print((0))

  exit()

L = []

for i in range(l,r):

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

    a = i*j

    b = a%2019

    L.append(b)

print((min(L)))

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

if r-l+1>2019:

  print((0))

  exit()

L = []

for i in range(l,r):

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

    a = i*j

    b = a%2019

    L.append(b)

    if b == 0:

      break

print((min(L)))

l, r = list(map(int, input().split()))
if r - l + 1 > 2019:
    print((0))
    exit()
L = []
for i in range(l, r):
    for j in range(i + 1, r + 1):
        a = i * j
        b = a % 2019
        L.append(b)
print((min(L)))

l, r = list(map(int, input().split()))
if r - l + 1 > 2019:
    print((0))
    exit()
L = []
for i in range(l, r):
    for j in range(i + 1, r + 1):
        a = i * j
        b = a % 2019
        L.append(b)
        if b == 0:
            break
print((min(L)))

+        if b == 0: +            break