#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
typedef long long LL;
priority_queue<LL, vector<LL>, greater<LL> > q,p;
int n,m,x=0;
string s;
string chaishu(int l)
{
string h;
int u=0;
for(;l!=0;l=l/10)
{
u=u*10+l%10;
}
while(u!=0)
{
h+=48+u%10;
u=u/10;
}
return h;
}
int main()
{
cin>>n>>m;
q.push(1);
p.push(1);
for(int i=1;i<=n;i++)
{
q.push(q.top()*2+1);
p.push(p.top()*4+5);
}
while(!p.empty())
{
q.push(p.top());
p.pop();
}
for(int i=1;i<=n;i++)
{
s+=chaishu(q.top());
q.pop();
}
cout<<s<<endl;
for(int i=0;i<s.length();i++)
{
if(s[i]>s[i-1]&&s[i]>s[i+1])
{
s.erase(i,1);
x++;
}
if(x==m) break;
}
cout<<s;
return 0;
}