#include <iostream>
using namespace std;
typedef long int ll;
ll num=-1,num1=-1;
int findmin(int num, int digits, int sum)
{
if(digits==0&& sum==0)
return num;
if(digits==0 && sum>0)
return 0;
if(digits!=0 && sum==0)
{
while(digits)
{
num=num*10;
digits--;
}
return num;
}
if(sum>0 && digits!=0)
{
int i;
for( i=0; i<=9;i++)
{
int p= findmin(num*10+i,digits-1,sum-i);
if(p!=0)
return p;
}
}
}
int findmax(int num1, int digits, int sum)
{
if(digits==0&& sum==0)
return num1;
if(digits==0 && sum<0)
return 0;
if(digits!=0 && sum==0)
{
while(digits)
{
num1=num1*10;
digits--;
}
return num1;
}
if(sum>0 && digits!=0)
{
int i;
for( i=9;i>=0;i--)
{
int p= findmax(num1*10+i,digits-1,sum-i);
if(p!=0)
return p;
}
}
return 0;
}
int main() {
// your code goes here
int n,sum,s;
cin>>n>>sum;
s=sum;
if(s==0)
cout<<"-1 -1";
else
{
int f=0;
ll res1;
for(int i=1;i<=9;i++)
{
num=i;
res1= findmin(num,n-1,sum-i);
if(res1!=0)
{
f++;
cout<<res1<<" ";
break;
}
}
ll res2;
for(int j=9;j>=1;j--)
{
num1=j;
res2= findmax(num1,n-1,s-j);
if(res2!=0)
{
f++;
cout<<res2<<" ";
break;
}
}
if(f!=2 || num1==-1 || num==-1)
cout<<"-1 -1";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGludCBsbDsKCmxsIG51bT0tMSxudW0xPS0xOwoKaW50IGZpbmRtaW4oaW50IG51bSwgaW50IGRpZ2l0cywgaW50IHN1bSkKewoJIGlmKGRpZ2l0cz09MCYmIHN1bT09MCkKCSByZXR1cm4gbnVtOwoJIAoJaWYoZGlnaXRzPT0wICYmIHN1bT4wKQoJIHJldHVybiAwOwoJIAoJaWYoZGlnaXRzIT0wICYmIHN1bT09MCkKCSB7CgkgCXdoaWxlKGRpZ2l0cykKCSAJewoJIAkJbnVtPW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