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

if r-l>672:

	p=0

else:

	p=2019

	for i in range(l, r):

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

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

			if not p:

				break

		if not p:

			break

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

if r-l>672:

	p=0

else:

	x=[]

	for i in range(l, r):

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

			x.append((i*j)%2019)

	p=min(x)

print(p)
l, r = list(map(int, input().split()))
if r - l > 672:
    p = 0
else:
    p = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            p = min(p, (i * j % 2019))
            if not p:
                break
        if not p:
            break
print(p)

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

-    p = 2019 +    x = [] -            p = min(p, (i * j % 2019)) -            if not p: -                break -        if not p: -            break +            x.append((i * j) % 2019) +    p = min(x)