//bfs只能过40%。
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a,b,c,dp[2028];
struct s
{int x,y,z;string m;
};
map<vector<int>,int>k;
signed main()
{ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);cin>>a>>b;queue<s>t;t.push({0,a,b,""});string l;while(!t.empty()){s h=t.front();t.pop();if(h.y==0&&h.z==0&&h.x==0){l=h.m;cout<<l<<endl;return 0;}if(h.z>=1){vector<int>ll;ll.push_back((h.x*10+3)%2023);ll.push_back(h.y);ll.push_back(h.z-1);if(k[ll]==0){k[ll]=1;t.push({(h.x*10+3)%2023,h.y,h.z-1,h.m+'3'});}}if(h.y>=1){vector<int>ll;ll.push_back((h.x*10+2)%2023);ll.push_back(h.y-1);ll.push_back(h.z);if(k[ll]==0){k[ll]=1;t.push({(h.x*10+2)%2023,h.y-1,h.z,h.m+'2'});}}}cout<<"-1"<<endl;
}