#include<iostream>
#include<cstring>
#include<algorithm>
#define Dist(x,y) ((x)*(x)+(y)*(y))
using namespace std;

typedef struct{
  int height;
  int weight;
} Rectangle;

bool operator<(Rectangle r1,Rectangle r2){
  int di1=Dist(r1.height,r1.weight);
  int di2=Dist(r2.height,r2.weight);
  if(di1 < di2) return true;
  else if(di1 > di2) return false;
  else return (r1.height < r2.height);
}

int main(){
  int h,w;
  while(cin>>h>>w,w+h){
    Rectangle r;
    r.height=h;
    r.weight=w;
    Rectangle min;
    min.height=150;
    min.weight=150;
    for(int i=1;i<150;i++){
      for(int j=1;j<i;j++){
	Rectangle tmp;
	tmp.height=j;
	tmp.weight=i;
	if(r < tmp && tmp < min) min = tmp;
      }
    }
    cout<<min.height<<" "<<min.weight<<endl;
  }
  return 0;
}
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    ll l,r;
    cin >> l >> r;
    if(l+1==r){
        cout << ((l%2019)*(r%2019))%2019 << endl;
        return 0;
    }

    if(l==0){
        cout << 0 << endl;
        return 0;
    }

    if(r-l+1>=673){
        cout << 0 << endl;
    }else{
        int m=2018;
        for(int i=l;i<r;i++){
            for(int j=i+1;j<=r;j++){
                m = min(m,((i%2019)*(j%2019))%2019);
            }
        }
       
        cout << m << endl;
    }
}