P1323
#include <bits/stdc++.h>
using namespace std;
priority_queue <int , vector<int> , greater<int> > pq;
int k , m;
string ans , ans1;
int main(){
pq.push(1);
cin >> k >> m;
int cnt = 0;
while(cnt < k){
int a = pq.top() * 2 + 1;
int b = pq.top() * 4 + 5;
ans += to_string(pq.top());
pq.pop();
pq.push(a);
pq.push(b);
++cnt;
}
cout << ans << '\n';
int l = 0 , r = m;
int maxx = 0;
while(l <= r && r <= ans.size()){
for(int i = l;i <= r;++i){
if((ans[i] - '0') > maxx){
maxx = (int)(ans[i] - '0');
l = i + 1;
}
}
ans1 += to_string(maxx);
r++;
maxx = 0;
}
cout << ans1;
return 0;
}