/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-21 17:49:52
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 1500+5;

struct Edge{
    int to,nxt;
}e[MAXN<<1];
int n,head[MAXN],x0,y00,cnt;

inline void add(int u,int v){
    e[++cnt] = (Edge){v,head[u]};head[u] = cnt;
    e[++cnt] = (Edge){u,head[v]};head[v] = cnt;
}

struct Point{
    int x,y;
    Point(int x=0,int y=0) : x(x),y(y) {}

    inline Point operator - (const Point &t) const {
        return Point(x-t.x,y-t.y);
    }

    inline int operator * (const Point &t){
        return x*t.y+y*t.x;
    }
}p[MAXN];

inline int cross(const Point &a,const Point &b,const Point &c=Point(x0,y00)){
    return (a-c)*(b-c);
//    return Point(a.x-c.x,a.y-c.y)*Point(b.x-c.x,b.y-c.y);
}

inline bool cmp(int u,int v){
    return cross(p[u],p[v]) < 0;
}

int ans[MAXN],sz[MAXN];

inline void dfs1(int v,int fa=0){
    sz[v] = 1;
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        dfs1(e[i].to,v);sz[v] += sz[e[i].to];
    }
}

inline void dfs(int v,int fa,std::vector<int> now){
//    DEBUG(v);DEBUG(now[0]);
//    for(auto x:now) DEBUG(x);
    if(now.size() == 1){
        ans[v] = now[0];
        //DEBUG(now[0]);
        now.clear();return;
    }
    x0 = y00 = 1e9;int ps = -1;
    FOR(i,0,(int)now.size()-1){
        if(x0 > p[now[i]].x){
            x0 = p[now[i]].x;
            y00 = p[now[i]].y;
            ps = i;
        }
        else if(x0 == p[now[i]].x && y00 > p[now[i]].y){
            x0 = p[now[i]].x;y00 = p[now[i]].y;
            ps = i;
        }
    }
    ans[v] = now[ps];
    now.erase(now.begin()+ps);
    std::sort(all(now),cmp);
   // puts("");
  //  DEBUG(cmp(now[1],now[2]));
   // for(auto x:now) printf("%d %d\n",p[x].x,p[x].y);
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        std::vector<int> t;
        FOR(j,0,sz[e[i].to]-1) t.pb(now[j]);
//        DEBUG(t.size());
        now.erase(now.begin(),now.begin()+sz[e[i].to]);
//        DEBUG(v);DEBUG(now.size());DEBUG(sz[e[i].to]);
 //       for(auto x:t) DEBUG(x);
 //       puts("");
 //       for(auto x:now) DEBUG(x);
 //       puts("");
        dfs(e[i].to,v,t);
    }
    now.clear();
}

int main(){
    scanf("%d",&n);
 //   DEBUG(n);
    FOR(i,1,n-1){
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);
    }
    std::vector<int> t;
    FOR(i,1,n){
        scanf("%d%d",&p[i].x,&p[i].y);t.pb(i);
    }
//    DEBUG((p[1]-p[3])*(p[4]-p[3]));
//    x0 = p[3].x;y00 = p[3].y;
//    DEBUG(cmp(1,4));
//    exit(0);
    std::sort(all(t),cmp);
    dfs1(1);dfs(1,0,t);
    FOR(i,1,n) printf("%d ",ans[i]);puts("");
    return 0;
}


/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-21 17:49:52
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
#define int LL
const int MAXN = 1500+5;

struct Edge{
    int to,nxt;
}e[MAXN<<1];
int n,head[MAXN],x0,y00,cnt;

inline void add(int u,int v){
    e[++cnt] = (Edge){v,head[u]};head[u] = cnt;
    e[++cnt] = (Edge){u,head[v]};head[v] = cnt;
}

struct Point{
    int x,y;
    Point(int x=0,int y=0) : x(x),y(y) {}

    inline Point operator - (const Point &t) const {
        return Point(x-t.x,y-t.y);
    }

    inline int operator * (const Point &t){
        return x*t.y+y*t.x;
    }
}p[MAXN];

inline int cross(const Point &a,const Point &b,const Point &c=Point(x0,y00)){
    return (a-c)*(b-c);
//    return Point(a.x-c.x,a.y-c.y)*Point(b.x-c.x,b.y-c.y);
}

inline bool cmp(int u,int v){
    return cross(p[u],p[v]) < 0;
}

int ans[MAXN],sz[MAXN];

inline void dfs1(int v,int fa=0){
    sz[v] = 1;
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        dfs1(e[i].to,v);sz[v] += sz[e[i].to];
    }
}

inline void dfs(int v,int fa,std::vector<int> now){
//    DEBUG(v);DEBUG(now[0]);
//    for(auto x:now) DEBUG(x);
    if(now.size() == 1){
        ans[v] = now[0];
        //DEBUG(now[0]);
        now.clear();return;
    }
    x0 = y00 = 1e9;int ps = -1;
    FOR(i,0,(int)now.size()-1){
        if(x0 > p[now[i]].x){
            x0 = p[now[i]].x;
            y00 = p[now[i]].y;
            ps = i;
        }
        else if(x0 == p[now[i]].x && y00 > p[now[i]].y){
            x0 = p[now[i]].x;y00 = p[now[i]].y;
            ps = i;
        }
    }
    ans[v] = now[ps];
    now.erase(now.begin()+ps);
    std::sort(all(now),cmp);
   // puts("");
  //  DEBUG(cmp(now[1],now[2]));
   // for(auto x:now) printf("%d %d\n",p[x].x,p[x].y);
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        std::vector<int> t;
        FOR(j,0,sz[e[i].to]-1) t.pb(now[j]);
//        DEBUG(t.size());
        now.erase(now.begin(),now.begin()+sz[e[i].to]);
//        DEBUG(v);DEBUG(now.size());DEBUG(sz[e[i].to]);
 //       for(auto x:t) DEBUG(x);
 //       puts("");
 //       for(auto x:now) DEBUG(x);
 //       puts("");
        dfs(e[i].to,v,t);
    }
    now.clear();
}

signed main(){
    scanf("%lld",&n);
 //   DEBUG(n);
    FOR(i,1,n-1){
        int u,v;scanf("%lld%lld",&u,&v);
        add(u,v);
    }
    std::vector<int> t;
    FOR(i,1,n){
        scanf("%lld%lld",&p[i].x,&p[i].y);t.pb(i);
    }
//    DEBUG((p[1]-p[3])*(p[4]-p[3]));
//    x0 = p[3].x;y00 = p[3].y;
//    DEBUG(cmp(1,4));
//    exit(0);
    std::sort(all(t),cmp);
    dfs1(1);dfs(1,0,t);
    FOR(i,1,n) printf("%lld ",ans[i]);puts("");
    return 0;
}


/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-21 17:49:52
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
#define int LL
const int MAXN = 3000+5;
const double EPS = 1e-8;

struct Edge{
    int to,nxt;
}e[MAXN<<1];
int n,head[MAXN],x0,y00,cnt;

inline void add(int u,int v){
    e[++cnt] = (Edge){v,head[u]};head[u] = cnt;
    e[++cnt] = (Edge){u,head[v]};head[v] = cnt;
}

struct Point{
    int x,y;
    Point(int x=0,int y=0) : x(x),y(y) {}

    inline Point operator - (const Point &t) const {
        return Point(x-t.x,y-t.y);
    }

    inline double operator * (const Point &t){
        DEBUG(1.0*x*t.y+1.0*y*t.x);
        return 1.0*x*t.y+1.0*y*t.x;
    }

    inline double deg(){
        return atan(1.0*y/x);
    }
}p[MAXN];

inline int cross(const Point &a,const Point &b,const Point &c=Point(x0,y00)){
    return (a-c)*(b-c);
//    return Point(a.x-c.x,a.y-c.y)*Point(b.x-c.x,b.y-c.y);
}

inline int sgn(double x){
    if(std::abs(x) <= EPS) return 0;
    return x > 0 ? 1 : -1;
}

inline bool cmp(int u,int v){
    return sgn((p[u]-Point(x0,y00)).deg()-(p[v]-Point(x0,y00)).deg()) < 0;
//    DEBUG(cross(p[u],p[v]));
//    return sgn(cross(p[u],p[v])) < 0;
}

int ans[MAXN],sz[MAXN];

inline void dfs1(int v,int fa=0){
    sz[v] = 1;
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        dfs1(e[i].to,v);sz[v] += sz[e[i].to];
    }
}

inline void dfs(int v,int fa,std::vector<int> now){
    if(now.size() == 1){
        ans[v] = now[0];
        now.clear();return;
    }
    x0 = y00 = 1e18;int ps = -1;
    FOR(i,0,(int)now.size()-1){
        if(x0 > p[now[i]].x){
            x0 = p[now[i]].x;
            y00 = p[now[i]].y;
            ps = i;
        }
        else if(x0 == p[now[i]].x && y00 > p[now[i]].y){
            x0 = p[now[i]].x;y00 = p[now[i]].y;
            ps = i;
        }
    }
    ans[v] = now[ps];
    now.erase(now.begin()+ps);
    std::sort(all(now),cmp);
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        std::vector<int> t;
        FOR(j,0,sz[e[i].to]-1) t.pb(now[j]);
        now.erase(now.begin(),now.begin()+sz[e[i].to]);
        dfs(e[i].to,v,t);
    }
    now.clear();
}

signed main(){
//    freopen("test.in","r",stdin);
//    freopen("test.out","w",stdout);
    scanf("%lld",&n);
 //   DEBUG(n);
    FOR(i,1,n-1){
        int u,v;scanf("%lld%lld",&u,&v);
        add(u,v);
    }
    std::vector<int> t;
    FOR(i,1,n){
        scanf("%lld%lld",&p[i].x,&p[i].y);t.pb(i);
    }
//    DEBUG((p[1]-p[3])*(p[4]-p[3]));
//    x0 = p[3].x;y00 = p[3].y;
//    DEBUG(cmp(1,4));
//    exit(0);
    std::sort(all(t),cmp);
    dfs1(1);
    dfs(1,0,t);
    FOR(i,1,n) printf("%lld ",ans[i]);puts("");
    return 0;
}


/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-21 17:49:52
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 1500+5;
const double EPS = 1e-8;

struct Edge{
    int to,nxt;
}e[MAXN<<1];
int n,head[MAXN],x0,y00,cnt;

inline void add(int u,int v){
    e[++cnt] = (Edge){v,head[u]};head[u] = cnt;
    e[++cnt] = (Edge){u,head[v]};head[v] = cnt;
}

struct Point{
    int x,y,id;
    Point(int x=0,int y=0) : x(x),y(y) {}

    inline Point operator - (const Point &t) const {
        return Point(x-t.x,y-t.y);
    }

    inline double operator * (const Point &t){
 //       DEBUG(1.0*x*t.y+1.0*y*t.x);
        return 1.0*x*t.y+1.0*y*t.x;
    }

    inline double deg(){
        return atan(1.0*y/x);
    }
}p[MAXN],p0;

inline int sgn(double x){
    if(std::abs(x) <= EPS) return 0;
    return x > 0 ? 1 : -1;
}

inline bool cmp(const Point &u,const Point &v){
    return sgn((u-p0).deg()-(v-p0).deg()) < 0;
}

int ans[MAXN],sz[MAXN];

inline void dfs1(int v,int fa=0){
    sz[v] = 1;
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        dfs1(e[i].to,v);sz[v] += sz[e[i].to];
    }
}

inline void dfs(int v,int fa,int l,int r){
    int ps = l;
    FOR(i,l+1,r){
        if(p[i].x < p[ps].x || (p[i].x == p[ps].x && p[i].y < p[ps].y)) ps = i;
    }
    std::swap(p[l],p[ps]);p0 = p[l];
    ans[p[l].id] = v;
    std::sort(p+l+1,p+r+1,cmp);
    int now = l+1;
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        dfs(e[i].to,v,now,now+sz[e[i].to]-1);
        now = now+sz[e[i].to];
    }
}

signed main(){
//    freopen("test.in","r",stdin);
//    freopen("test.out","w",stdout);
    scanf("%d",&n);
    FOR(i,1,n-1){
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);
    }
    FOR(i,1,n){
        scanf("%d%d",&p[i].x,&p[i].y);
        std::swap(p[i].x,p[i].y);
        p[i].id = i;
    }
    dfs1(1);
    dfs(1,0,1,n);
    FOR(i,1,n) printf("%d ",ans[i]);puts("");
    return 0;
}


/*
By Tianyi Chen. All rights reserved.
Date: 2016-07-24
*/
#include<bits/stdc++.h>
using namespace std;vector<int>te[1501];bool visited[1501];int n,_,__,subsize[1501],ans[1501];struct point { int64_t x,y;int id;void read() { scanf("%lld%lld",&x,&y); } }p[1501];int dfs(int i) { int rt=1;visited[i]=1; for (auto&&x:te[i])if (!visited[x])rt+=dfs(x); return subsize[i]=rt;}void build(int i,int b) { visited[i]=1; swap(*min_element(p+b,p+b+subsize[i],[](const point&i,const point&j) {return i.y!=j.y?i.y<j.y:i.x<j.x;}),p[b]); sort(p+b+1,p+b+subsize[i],[&](const point&i,const point&j) {  return (i.x-p[b].x)*(j.y-p[b].y)-(j.x-p[b].x)*(i.y-p[b].y)<0; }); ans[i]=p[b].id; ++b; for (auto&&x:te[i])if (!visited[x]) {  build(x,b);  b+=subsize[x]; }}int main() { scanf("%d",&n);for(int i=1;i<n;++i)scanf("%d%d",&_,&__),te[_].push_back(__),te[__].push_back(_); dfs(1);memset(visited,0,sizeof visited); for(int i=0;i<n;++i)p[i].id=i+1,p[i].read(); build(1,1); for(int i=1;i<=n;++i)printf("%d ",ans[i]);}


/*
By Tianyi Chen. All rights reserved.
Date: 2016-07-24
*/
#include<bits/stdc++.h>
using namespace std;vector<int>te[1501];bool visited[1501];int n,_,__,subsize[1501],ans[1501];struct point { int64_t x,y;int id;void read() { scanf("%lld%lld",&x,&y); } }p[1501];int dfs(int i) { int rt=1;visited[i]=1; for (auto&&x:te[i])if (!visited[x])rt+=dfs(x); return subsize[i]=rt;}void build(int i,int b) { int est=b+subsize[i]; visited[i]=1; swap(*min_element(p+b,p+b+subsize[i],[](const point&i,const point&j) {return i.y!=j.y?i.y<j.y:i.x<j.x;}),p[b]);
sort(p+b+1,p+b+subsize[i],[&](const point&i,const point&j) {  return (i.x-p[b].x)*(j.y-p[b].y)-(j.x-p[b].x)*(i.y-p[b].y)<0; }); ans[p[b].id]=i; ++b; for (auto&&x:te[i])if (!visited[x]) {  build(x,b);  b+=subsize[x]; } if (b!=est)throw;}int main() { scanf("%d",&n);for(int i=1;i<n;++i)scanf("%d%d",&_,&__),te[_].push_back(__),te[__].push_back(_); dfs(1);memset(visited,0,sizeof visited); for(int i=0;i<n;++i)p[i].id=i,p[i].read(); build(1,0); for(int i=0;i<n;++i)printf("%d ",ans[i]);}


/*
By Tianyi Chen. All rights reserved.
Date: 2016-07-24
*/
#include<bits/stdc++.h>
using namespace std;vector<int>te[1501];bool visited[1501];int n,_,__,subsize[1501],ans[1501];struct point { int64_t x,y;int id;void read() { scanf("%lld%lld",&x,&y); } }p[1501];int dfs(int i) { int rt=1;visited[i]=1; for (auto&&x:te[i])if (!visited[x])rt+=dfs(x); return subsize[i]=rt;}void build(int i,int b) { int est=b+subsize[i]; visited[i]=1; swap(*min_element(p+b,p+b+subsize[i],[](const point&i,const point&j) {return i.y!=j.y?i.y<j.y:i.x<j.x;}),p[b]);
sort(p+b+1,p+b+subsize[i],[&](const point&i,const point&j) {  return (i.x-p[b].x)*(j.y-p[b].y)-(j.x-p[b].x)*(i.y-p[b].y)<0; }); ans[p[b].id]=i; ++b; for (auto&&x:te[i])if (!visited[x]) {  build(x,b);  b+=subsize[x]; } if (b!=est)throw;}int main() { scanf("%d",&n);for(int i=1;i<n;++i)scanf("%d%d",&_,&__),te[_].push_back(__),te[__].push_back(_); dfs(1);memset(visited,0,sizeof visited); for(int i=0;i<n;++i)p[i].id=i,p[i].read(); build(1,0); for(int i=0;i<n;++i)printf("%d ",ans[i]);_Exit(0);}


#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <string.h>
#include <iomanip>
#include <utility>
#define INF 0x3fffffff
using namespace std;
int n, m, k, t, p, q, x, y;
string s;
int w[30];
int a[20];
int demand[1005];

string ss[5] = { "S", "M", "L", "XL", "XXL" };

int main() {
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s; int index = 0;
        if (s == "S") index = 0;
        if (s == "M") index = 1;
        if (s == "L") index = 2;
        if (s == "XL") index = 3;
        if (s == "XXL") index = 4;
        if (a[index]) {
            cout << ss[index] << endl;
            a[index]--;
            continue;
        }

        for (int i = 1; i <= 4; i++) {
            if (a[index + i]) {
                cout << ss[index + i] << endl;
                a[index + i]--;
                break;
            }
            if (index - i >= 0 && a[index - i]) {
                cout << ss[index + i] << endl;
                a[index - i]--;
                break;
            }
        }
    }

    return 0;
}


#include "stdafx.h"

#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <string.h>
#include <iomanip>
#include <utility>
#define INF 0x3fffffff
using namespace std;
int n, m, k, t, p, q, x, y;
string s;
int w[30];
int a[20];
int demand[1005];

string ss[5] = { "S", "M", "L", "XL", "XXL" };

int main() {
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s; int index = 0;
        if (s == "S") index = 0;
        if (s == "M") index = 1;
        if (s == "L") index = 2;
        if (s == "XL") index = 3;
        if (s == "XXL") index = 4;
        if (a[index]) {
            cout << ss[index] << endl;
            a[index]--;
            continue;
        }

        for (int i = 1; i <= 4; i++) {
            if (a[index + i]) {
                cout << ss[index + i] << endl;
                a[index + i]--;
                break;
            }
            if (index - i >= 0 && a[index - i]) {
                cout << ss[index - i] << endl;
                a[index - i]--;
                break;
            }
        }
    }

    return 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <string.h>
#include <iomanip>
#include <utility>
#define INF 0x3fffffff
using namespace std;
int n, m, k, t, p, q, x, y;
string s;
int w[30];
int a[20];
int demand[1005];

string ss[5] = { "S", "M", "L", "XL", "XXL" };

int main() {
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s; int index = 0;
        if (s == "S") index = 0;
        if (s == "M") index = 1;
        if (s == "L") index = 2;
        if (s == "XL") index = 3;
        if (s == "XXL") index = 4;
        if (a[index]) {
            cout << ss[index] << endl;
            a[index]--;
            continue;
        }

        for (int i = 1; i <= 4; i++) {
            if (a[index + i]) {
                cout << ss[index + i] << endl;
                a[index + i]--;
                break;
            }
            if (index - i >= 0 && a[index - i]) {
                cout << ss[index - i] << endl;
                a[index - i]--;
                break;
            }
        }
    }

    return 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <string.h>
#include <iomanip>
#include <utility>
#define INF 0x3fffffff
using namespace std;
int n, m, k, t, p, q, x, y;
string s;
int w[30];
int a[6];
int demand[1005];

string ss[5] = { "S", "M", "L", "XL", "XXL" };

int main() {
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s; int index = 0;
        if (s == "S") index = 0;
        if (s == "M") index = 1;
        if (s == "L") index = 2;
        if (s == "XL") index = 3;
        if (s == "XXL") index = 4;
        if (a[index]) {
            cout << ss[index] << endl;
            a[index]--;
            continue;
        }
        if (a[index + 1]) {
            cout << ss[index + 1] << endl;
            a[index + 1]--;
            continue;
        }
        if (a[index - 1] && index != 0) {
            cout << ss[index - 1] << endl;
            a[index - 1]--;
        }
        if (a[index + 2]) {
            cout << ss[index + 2] << endl;
            a[index + 2]--;
        }
        if (a[index - 2] && index != 1) {
            cout << ss[index - 2] << endl;
            a[index - 2]--;
        }
    }

    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<string>
using namespace std;
int a[5],b[1005],k,d[8]={1,-1,2,-2,3,-3,4,-4};
string s[1005];

int main()
{
	for(int i=0;i<5;i++)
	cin>>a[i] ;
	cin>>k;
	for(int i=0;i<k;i++)
	{
		cin>>s[i];
		if(s[i]=="S")
		b[i]=0;
		else if(s[i]=="M")
		b[i]=1;
		else if(s[i]=="L")
		b[i]=2;
		else if(s[i]=="XL")
		b[i]=3;
		else if(s[i]=="XXL")
		b[i]=4;
	}
	for(int i=0;i<k;i++)
	{
		for(int j=0;j<5;j++)
		{
			if(b[i]==j&&a[j]>0)
			{
				if(b[i]==0)
		        cout<<"S"<<endl;
		        else if(b[i]==1)
		        cout<<"M"<<endl;
		        else if(b[i]==2)
		        cout<<"L"<<endl;
		        else if(b[i]==3)
		        cout<<"XL"<<endl;
		        else if(b[i]==4)
		        cout<<"XXL"<<endl;
				a[j]--;
				break;
			}
			else if(b[i]==j&&a[j]==0)
			{
				for(int p=0;p<8;p++)
				{
					if(a[j+d[p]]!=0&&j+d[p]>=0&&j+d[p]<5)
					{
						if(j+d[p]==0)
		                cout<<"S"<<endl;
		                  else if(j+d[p]==1)
		                   cout<<"M"<<endl;
		                 else if(j+d[p]==2)
		                 cout<<"L"<<endl;
		                   else if(j+d[p]==3)
		                 cout<<"XL"<<endl;
		                  else if(j+d[p]==4)
		                  cout<<"XXL"<<endl;
				         a[j+d[p]]--;
				        break;
					}
				}
			}
		}
	}
}


#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int MAXK = 1000;
const int MAXS = 5;
int a[MAXS];
string b[MAXS] = {"S", "M", "L", "XL", "XXL"};

int main()
{
	int k;
	for(int i = 0; i < MAXS; i++)
		cin >> a[i];
	cin >> k;
	for(int i = 0; i < k; i++)
	{
		string s;
		bool c = false;
		int t;
		cin >> s;
		for(int j = 0; j < MAXS; j++)
			if(s == b[j])
				t = j;
		for(int j = t; j < MAXS; j++)
			if(a[j])
			{
				a[j]--;
				cout << b[j] << endl;
				c = true;
				break;
			}
		if(c)
			continue;
		for(int j = 0; j < t; j++)
			if(a[t - j - 1])
			{
				a[t - j - 1]--;
				cout << b[t - j - 1] << endl;
				break;
			}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int MAXK = 1000;
const int MAXS = 5;
int a[MAXS];
string b[MAXS] = {"S", "M", "L", "XL", "XXL"};

int main()
{
	int k;
	for(int i = 0; i < MAXS; i++)
		cin >> a[i];
	cin >> k;
	for(int i = 0; i < k; i++)
	{
		string s;
		bool c = false;
		int t;
		cin >> s;
		for(int j = 0; j < MAXS; j++)
			if(s == b[j])
				t = j;
		if(a[t])
		{
			a[t]--;
			cout << b[t] << endl;
			continue;
		}
		else
		for(int j = 1; j < MAXS; j++)
		{
			if(t + j < MAXS && a[t + j])
			{
				a[t + j]--;
				cout << b[t + j] << endl;
				break;
			}
			else if(t - j >= 0 && a[t - j])
			{
				a[t - j]--;
				cout << b[t - j] << endl;
				break;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int MAXK = 1000;
const int MAXS = 5;
int a[MAXS];
string b[MAXS] = {"S", "M", "L", "XL", "XXL"};

int main()
{
	int k;
	for(int i = 0; i < MAXS; i++)
		cin >> a[i];
	cin >> k;
	for(int i = 0; i < k; i++)
	{
		string s;
		bool c = false;
		int t;
		cin >> s;
		for(int j = 0; j < MAXS; j++)
			if(s == b[j])
				t = j;
		if(a[t])
		{
			a[t]--;
			cout << b[t] << endl;
			continue;
		}
		else
		for(int j = 1; j < MAXS; j++)
		{
			if(t + j < MAXS && a[t + j])
			{
				a[t + j]--;
				cout << b[t + j] << endl;
				break;
			}
			else if(t - j >= 0 && a[t - j - 1])
			{
				a[t - j]--;
				cout << b[t - j] << endl;
				break;
			}
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int in = 0;
	int snn = 0;
	int s;
	int sdd;
	int sn = n;
	if (n >= 18)
	{
		sn = 99;
	}
	if (n >= 27)
		sn = 999;
	for (int i = sn; i < 2230; i++)
	{

		for (int j = i + 1; j < 2230; j++)
		{
			snn = 0;
			sdd = j;
			for (int k = 0;; k++)
			{
				s = sdd % 10;
				snn += s;
				sdd = sdd / 10;
				if (sdd == 0)
					break;
			}
			if (snn >= n)
			{
				int ans = i + j;
				int t;
				int sum = 0;
				for (int k = 0;; k++)
				{
					t = ans % 10;
					sum += t;
					ans = ans / 10;
					if (ans == 0)
					{
						if (sum <= m)
						{
							cout << i << endl << j << endl;
							return 0;
						}
						break;
					}
				}
			}
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = n;; i++)
	{
		for (int j = n + 1;; j++)
		{
			int ans = i + j;
			int t;
			int sum = 0;
			for (int k = 0;; k++)
			{
				t = ans % 10;
				sum += t;
				ans = ans / 10;
				if (ans == 0)
				{
					if (sum <= m)
					{
						cout << i << " " << j << endl;
						return 0;
					}
					break;
				}
			}
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int in = 0;
	int snn = 0;
	int s;
	int sdd;
	int sn = n;
	if (n >= 18)
	{
		sn = 99;
	}
	if (n >= 27)
		sn = 999;
	for (int i = sn; i < 2230; i++)
	{
		int st = i;
		int sst = 0;
		int sssum = 0;
		for (int k = 0;; k++)
		{
			sst = st % 10;
			st = st / 10;
			sssum += sst;
			if (st == 0)
				break;
		}
		if(sssum>=n)
		for (int j = i + 1; j < 2230; j++)
		{
			snn = 0;
			sdd = j;
			for (int k = 0;; k++)
			{
				s = sdd % 10;
				snn += s;
				sdd = sdd / 10;
				if (sdd == 0)
					break;
			}
			if (snn >= n)
			{
				int ans = i + j;
				int t;
				int sum = 0;
				for (int k = 0;; k++)
				{
					t = ans % 10;
					sum += t;
					ans = ans / 10;
					if (ans == 0)
					{
						cout << sum << endl;
						if (sum <= m)
						{
							cout << i << endl << j << endl;
							return 0;
						}
						break;
					}
				}
			}
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int in = 0;
	int snn = 0;
	int s;
	int sdd;
	int sn = n;
	if (n >= 18)
	{
		sn = 99;
	}
	if (n >= 27)
		sn = 999;
	for (int i = sn; i < 2230; i++)
	{
		int st = i;
		int sst = 0;
		int sssum = 0;
		for (int k = 0;; k++)
		{
			sst = st % 10;
			st = st / 10;
			sssum += sst;
			if (st == 0)
				break;
		}
		if(sssum>=n)
		for (int j = i + 1; j < 2230; j++)
		{
			snn = 0;
			sdd = j;
			for (int k = 0;; k++)
			{
				s = sdd % 10;
				snn += s;
				sdd = sdd / 10;
				if (sdd == 0)
					break;
			}
			if (snn >= n)
			{
				int ans = i + j;
				int t;
				int sum = 0;
				for (int k = 0;; k++)
				{
					t = ans % 10;
					sum += t;
					ans = ans / 10;
					if (ans == 0)
					{
						if (sum <= m)
						{
							cout << i << endl << j << endl;
							return 0;
						}
						break;
					}
				}
			}
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = n;; i++)
	{
		int k = n + 1;
		int in = 0;
		int snn = 0;
		int s;
		int sdd;
		for (int j = n + 1;; j++)
		{
			snn = 0;
			sdd = j;
			for (int k = 0;; k++)
			{
				s = sdd % 10;
				snn += s;
				sdd = sdd / 10;
				if (sdd == 0)
					break;
			}
			if (snn >= n)
			{
				int ans = i + j;
				int t;
				int sum = 0;
				for (int k = 0;; k++)
				{
					t = ans % 10;
					sum += t;
					ans = ans / 10;
					if (ans == 0)
					{
						if (sum <= m)
						{
							cout << i << " " << j << endl;
							return 0;
						}
						break;
					}
				}
			}
		}
	}
	return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}
string ss(LL x)
{
    string s;
    for(int i=0; i<2000 ; i++ )
    {
        if(x>0)
        {
            if(x>9)
                s+='9',
                x-=9;
            else
                s+=(x+'0'-1 ),
                x=0;

        }
        else
            s+='9';
    }
    return s;
}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    LL a=n;
   // LL res=sum(m);
    LL sd=sum(n);
    string s=ss(m+sd);
    for(int i=1999 ; i>=0 ; i++)
    {
        if(n>0)
        {
            LL v=n%10;
            if(i==1999)
                s[i]=(10-v+'0' );
            else
                s[i]=(9-v+'0');
            n/=10;
        }
        else
            break;
    }

    cout<<a<<endl<<s<<endl;

    return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}
string ss(LL x)
{
    string s;
    for(int i=0; i<2230 ; i++ )
    {
        if(x>0)
        {
            if(x>9)
                s+='9',
                x-=9;
            else
                s+=(x+'0'-1 ),
                x=0;

        }
        else
            s+='9';
    }
    return s;
}
LL gen(LL x)
{
    LL res=0;
    while(x>0)
    {
        if(x>9)
            res=res*10+9;
        else
            res=res*10+x;
        x-=9;
    }
    return res;

}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    string s1,s2;
    for(int i=0; i<2229 ; i++)
    {
        s1+='5';
        s2+='4';
    }
    s1+='5';
    s2+='5';

    cout<<s1<<endl<<s2<<endl;

    return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}
string ss(LL x)
{
    string s;
    for(int i=0; i<2000 ; i++ )
    {
        if(x>0)
        {
            if(x>9)
                s+='9',
                x-=9;
            else
                s+=(x+'0'-1 ),
                x=0;

        }
        else
            s+='9';
    }
    return s;
}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    LL a=n;
   // LL res=sum(m);
  // LL sd=sum(n);
    string s=ss(m);
    for(int i=1999 ; i>=0 ; i++)
    {
        if(n>0)
        {
            LL v=n%10;
            if(i==1999)
                s[i]=(10-v+'0' );
            else
                s[i]=(9-v+'0');
            n/=10;
        }
        else
            break;
    }

    cout<<a<<endl<<s<<endl;

    return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}
string ss(LL x)
{
    string s;
    for(int i=0; i<2230 ; i++ )
    {
        if(x>0)
        {
            if(x>9)
                s+='9',
                x-=9;
            else
                s+=(x+'0'-1 ),
                x=0;

        }
        else
            s+='9';
    }
    return s;
}
LL gen(LL x)
{
    LL res=0;
    while(x>0)
    {
        if(x>9)
            res=res*10+9;
        else
            res=res*10+x;
        x-=9;
    }
    return res;

}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    LL a=gen(n);
    LL b=a;
   // cout<<a<<endl;
   // LL res=sum(m);
  // LL sd=sum(n);
    string s=ss(m-1);
    for(int i=2229 ; i>=0 ; i--)
    {
        if(n>0)
        {
            LL v=a%10;
            if(i==2229)
                s[i]=(10-v+'0' );
            else
                s[i]=(9-v+'0');
            a/=10;
        }
        else
            break;
    }

    cout<<b<<endl<<s<<endl;

    return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}
string ss(LL x)
{
    string s;
    for(int i=0; i<2230 ; i++ )
    {
        if(x>0)
        {
            if(x>9)
                s+='9',
                x-=9;
            else
                s+=(x+'0'-1 ),
                x=0;

        }
        else
            s+='9';
    }
    return s;
}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    LL a=n;
   // LL res=sum(m);
  // LL sd=sum(n);
    string s=ss(m-1);
    for(int i=2229 ; i>=0 ; i++)
    {
        if(n>0)
        {
            LL v=n%10;
            if(i==2229)
                s[i]=(10-v+'0' );
            else
                s[i]=(9-v+'0');
            n/=10;
        }
        else
            break;
    }

    cout<<a<<endl<<s<<endl;

    return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    LL a=n,b=n+1;
    while(1)
    {
        LL res1=sum((a+b));
        LL res2=sum(b);
        if(res1<=m && res2>=n )
            break;
        else
            b++;
            //cout<<res1<<endl;

    }
    cout<<a<<endl<<b<<endl;

    return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}
string ss(LL x)
{
    string s;
    for(int i=0; i<2230 ; i++ )
    {
        if(x>0)
        {
            if(x>9)
                s+='9',
                x-=9;
            else
                s+=(x+'0'-1 ),
                x=0;

        }
        else
            s+='9';
    }
    return s;
}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    LL a=n;
   // LL res=sum(m);
  // LL sd=sum(n);
    string s=ss(m);
    for(int i=2229 ; i>=0 ; i++)
    {
        if(n>0)
        {
            LL v=n%10;
            if(i==2229)
                s[i]=(10-v+'0' );
            else
                s[i]=(9-v+'0');
            n/=10;
        }
        else
            break;
    }

    cout<<a<<endl<<s<<endl;

    return 0;
}


/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define S second
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define PI acos(-1)
#define MAX 200005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

LL sum(LL x)
{
    LL res=0;
    while(x>0)
    {
        res+=(x%10);
        x/=10;
    }
    return res;
}
string ss(LL x)
{
    string s;
    for(int i=0; i<2230 ; i++ )
    {
        if(x>0)
        {
            if(x>9)
                s+='9',
                x-=9;
            else
                s+=(x+'0'-1 ),
                x=0;

        }
        else
            s+='9';
    }
    return s;
}
LL gen(LL x)
{
    LL res=0;
    while(x>0)
    {
        if(x%10>9)
            res=res*10+9;
        else
            res=res*10+x;
        x-=9;
    }
    return res;

}

int main()
{
    IO
    LL n,m;
    cin>>n>>m;
    LL a=gen(n);
    LL b=a;
   // LL res=sum(m);
  // LL sd=sum(n);
    string s=ss(m-1);
    for(int i=2229 ; i>=0 ; i--)
    {
        if(n>0)
        {
            LL v=a%10;
            if(i==2229)
                s[i]=(10-v+'0' );
            else
                s[i]=(9-v+'0');
            a/=10;
        }
        else
            break;
    }

    cout<<b<<endl<<s<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=1000000007;

int main()
{
	string s;
	for(int i=0;i<2000;i++)
		s+='5';
	cout << endl;
	for(int i=1;i<2000;i++)
		s+='4';
	cout << '5';

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=1000000007;

int main()
{
	for(int i=0;i<2000;i++)
		cout << 1;
	cout << endl << 1 << endl;
	for(int i=0;i<2000;i++)
		cout << 0 ;
	cout << endl;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=1000000007;

int main()
{
	string s;
	for(int i=0;i<2000;i++)
		s+='1';
	cout << s << endl << s;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=1000000007;

int main()
{
	string s;
	for(int i=0;i<2000;i++)
		cout << '5';
	cout << endl;
	for(int i=1;i<2000;i++)
		cout << '4';
	cout << '5';

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=1000000007;

int main()
{
	string s;
	for(int i=0;i<2000;i++)
		s+='5';
	cout <<'5'<< s << endl <<'4'<< s;
}


#include <bits/stdc++.h>

using namespace std;

int main () {

	int n, m; scanf("%d %d", &n, &m);

	string s1, s2;

	for (int i = 0; i < 126; i++) s1 += '9';
	s2 = s1;

	int cont1 = 9*126;
	int cont2 = cont1;
	int sum = cont1 + cont2;

	if (sum > m) {
		int dif = sum - m;
		int qtd = dif/9;
		int rest = dif%9;
		int fim = s1.size()-1;

		int qtd1 = qtd / 2;
		int qtd2 = qtd / 2 + qtd%2;

		int rest1 = rest/2;
		int rest2 = rest/2 + rest%2;

		for (int i = 0; i < qtd1; i++) s1[fim-i] = '0';
		for (int i = 0; i < qtd2; i++) s2[fim-i] = '0';

		s1[fim-qtd1] = (char)('9'-rest1);
		s2[fim-qtd1] = (char)('9'-rest2);
	}

	cout << s1 << endl << s2 << endl;

	return 0;
}


#include <bits/stdc++.h>
int main () {
	int n, m; scanf("%d %d", &n, &m);
	printf("%d\n%d\n", n, 10000-n);
}


#include <bits/stdc++.h>

using namespace std;

int main () {

	int n, m; scanf("%d %d", &n, &m);

	string s1, s2;

	for (int i = 0; i < 2230; i++) s1 += '0';
	s1[0] = '9';
	s2 = s1;
	s2[0] = '1';

	cout << s1 << endl << s2 << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main () {
	int n, m; scanf("%d %d", &n, &m);
	string s1, s2;
	for (int i = 0; i < 1000; i++) { s1 += '5'; s2 += '4'; }
	s2[s2.size()-1] = '5';
	cout << s1 << endl << s2 << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main () {

	int n, m; scanf("%d %d", &n, &m);

	string s1, s2;

	for (int i = 0; i < 2230; i++) s1 += '9';
	s2 = s1;

	int cont1 = 2230*9;
	int cont2 = cont1;
	int sum = cont1 + cont2;

	if (sum > m) {
		int dif = sum - m;
		int qtd = dif/9;
		int rest = dif%9;
		int fim = s1.size()-1;

		int qtd1 = qtd / 2;
		int qtd2 = qtd / 2 + qtd%2;

		int rest1 = rest/2;
		int rest2 = rest/2 + rest%2;

		for (int i = 0; i < qtd1; i++) s1[fim-i] = '0';
		for (int i = 0; i < qtd2; i++) s2[fim-i] = '0';

		s1[fim-qtd1] = (char)('9'-rest1);
		s2[fim-qtd1] = (char)('9'-rest2);
	}

	cout << s1 << endl << s2 << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main () {
	int n, m; scanf("%d %d", &n, &m);
	string s1, s2;
	for (int i = 0; i < 1000; i++) { s1 += '7'; s2 += '3'; }
	s2[s2.size()-1] = '7';
	cout << s1 << endl << s2 << endl;
}


#include <bits/stdc++.h>
using namespace std;

char mp[300][300];

int fun(int x)
{
    int sum = 0;
    while(x > 0)
    {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);

    for(int i = 1; i <= 3000; i++)
    {
        if(fun(i) < n) continue;
        for(int j = i+1; j <= 3000; j++)
        {
            if(fun(j) >= n && fun(i+j) <= m)
            {
                printf("%d %d\n",i,j);
                return 0;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

char mp[300][300];

int fun(int x)
{
    int sum = 0;
    while(x > 0)
    {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);

    for(int i = 0; i < 1000; i++)
        printf("5");
    printf("\n");
    for(int i = 0; i < 2000; i++)
        printf("4");
    printf("\n");

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
    char str[20];
    while(scanf("%s",str) && strcmp(str,"0") != 0) {
        int point,len = strlen(str);
        for(int i = 2; i < len; i++) {
            if(str[i] == '.') {
                point = i;
                break;
            }
        }
        long long ans_num = 0x3f3f3f3f;
        long long ans_cnt;
        for(int i = 2; i < point; i++) {
            long long cnt = 0, num = 0;
            for(int k = i; k < point; k++) {
                cnt = cnt * 10 + (str[k] - '0');
                num = num * 10 + 9;
            }
            long long inter = 0;
            for(int k = 2; k < i; k++)
                inter = inter * 10 + (str[k] - '0');
            cnt += inter * num;
            for(int k = 2; k < i; k++)
                num *= 10;
            long long res = __gcd(cnt,num);
            cnt /= res;
            num /= res;
            if(num < ans_num) {
                ans_num = num;
                ans_cnt = cnt;
            }
        }
        printf("%lld/%lld\n",ans_cnt,ans_num);
    }
    return 0;
}


/*
* (1) �ҵ����һ�����ֵ�λ��
* (2) ö��ѭ���ڳ���
* (3) ���ѭ��С�����ӵ�һ����ʼ����Ҫ����ǰ�治ѭ�����֣����Է�ĸ�ӵ������ϣ���ĸ*10^n��
* (4) �ҷ��ӷ�ĸgcd Լ�� ������С��ĸ�ķ�ʽ
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char str[100];
int main()
{
    while(scanf("%s",str) && strcmp(str,"0") != 0) {
        int point, len = strlen(str);
        for(int i = 2; i < len; i++) {
            if(str[i] == '.') {
                point = i;
                break;
            }
        }
        long long ans_num = 0x3f3f3f3f, ans_cnt;
        for(int i = 2; i < point; i++) {
            long long num = 0, cnt = 0;
            for(int k = i; k < point; k++) {
                cnt = cnt * 10 + (str[k] - '0');
                num += num * 10 + 9;
            }
            long long inter = 0;
            for(int k = 2; k < i; k++) {
                inter = inter * 10 + (str[k] - '0');
            }
            cnt += inter * num;
            for(int k = 2; k < i; k++) {
                num *= 10;
            }
            long long res = __gcd(cnt,num);
            cnt /= res;
            num /= res;
            if(num < ans_num){
                ans_num = num;
                ans_cnt = cnt;
            }
        }
        printf("%lld/%lld\n",ans_cnt,ans_num);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

char mp[300][300];

int fun(int x)
{
    int sum = 0;
    while(x > 0)
    {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);

    for(int i = 0; i < 1000; i++) puts("5");
    printf("\n");
    for(int i = 0; i < 1000; i++) puts("4");
    printf("\n");

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

char mp[300][300];

int fun(int x)
{
    int sum = 0;
    while(x > 0)
    {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);

    for(int i = 0; i < 1000; i++)
        putchar('5');
    puts(" ");
    for(int i = 0; i < 999; i++)
        putchar('4');
    puts("5");

    return 0;
}


#include <iostream>

using namespace std;

int main(){
    int n ,m ;
    cin >> n >> m;

    int left = n - 5*(m-1);

    int d = left/9 + 1;
    for(int i = 0 ; i < m - 1; i++){
        cout << '5';
    }

    if( m- 1 > 0){
        for(int i = 0 ; i < d ; i++){
            cout << '0';
        }
    }

    for(int i = 0 ; i < d - 1; i++){
        cout << '9';
    }

    cout << '9';
    cout << endl;

    for(int i = 0 ; i < m - 1; i++){
        cout << '5';
    }

    for(int i = 0 ; i < d; i++){
        cout << '9';
    }

    for(int i = 0 ; i < d - 1 ; i++){
        cout << '0';
    }
    cout << '1';
    cout << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main(){
    int n ,m ;
    cin >> n >> m;

    int left = n - 5*(m-1);

    int d = left/9 + 1;
    for(int i = 0 ; i < m - 1; i++){
        cout << '5';
    }

    for(int i = 0 ; i < d ; i++){
        cout << '0';
    }

    for(int i = 0 ; i < d; i++){
        cout << '9';
    }

    cout << endl;

    for(int i = 0 ; i < m - 1; i++){
        cout << '5';
    }

    for(int i = 0 ; i < d; i++){
        cout << '9';
    }

    for(int i = 0 ; i < d - 1 ; i++){
        cout << '0';
    }
    cout << '1';
    cout << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main(){
    int n ,m ;
    cin >> n >> m;
    bool is_4 = true;
    int sum = 0;
    int zs = 0;
    while( 5 * (m - 1)  + sum < n ){
        if(is_4){
            sum += 4;
        }
        else{
            sum += 6;
        }
        zs++;
        is_4 = !is_4;
    }

    for(int i = 0; i < m - 1; i++){
        cout << '5';
    }
    for(int i = 0; i <= zs ; i++){
        if( i % 2 == 0){
            cout << '4';
        }
        else{
            cout << '6';
        }
    }
    cout << endl;

    for(int i = 0; i < m - 1; i++){
        cout << '5';
    }
    for(int i = 0; i <= zs ; i++){
        if( i % 2 != 0){
            cout << '4';
        }
        else{
            cout << '6';
        }
    }
    cout << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main(){
    int n ,m ;
    cin >> n >> m;

    int left = n - 5*(m-1);

    int d = left/9 + 1;
    for(int i = 0 ; i < m - 1; i++){
        cout << '5';
    }

    for(int i = 0 ; i < d ; i++){
        cout << '0';
    }

    for(int i = 0 ; i < d - 1; i++){
        cout << '9';
    }

    cout << '9';
    cout << endl;

    for(int i = 0 ; i < m - 1; i++){
        cout << '5';
    }

    for(int i = 0 ; i < d; i++){
        cout << '9';
    }

    for(int i = 0 ; i < d - 1 ; i++){
        cout << '0';
    }
    cout << '1';
    cout << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main(){
    int n ,m ;
    cin >> n >> m;
    lotsOf5(m-1,false);
    lotsOf5(m-2,true);
    return 0;
}

void lotsOf5(int n, bool hv6){
    for(int i = 0 ; i < n ; i++){
        cout << '5';
    }
    if(hv6) cout << '6';
    cout << endl;
}


#include <iostream>

using namespace std;

void lotsOf5(int n, bool hv6);
int main(){
    int n ,m ;
    cin >> n >> m;
    lotsOf5(m-1,false);
    lotsOf5(m-2,true);
    return 0;
}

void lotsOf5(int n, bool hv6){
    for(int i = 0 ; i < n ; i++){
        cout << '5';
    }
    if(hv6) cout << '6';
    cout << endl;
}


#include <iostream>

using namespace std;

int main(){
    int n ,m ;
    cin >> n >> m;

    int left = n - 5*(m-1);
    cout << left << endl;
    if(left <= 5){
        for(int i = 0 ; i < m ; i++){
            cout << '5';
        }
        cout << endl;
        for(int i = 0 ; i < m ; i++){
            cout << '5';
        }
        cout << endl;
    }
    else{
        int r = left%9;
        if( r > 5 ){
            int d = left/9 + 1;
            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }

            for(int i = 0 ; i < d ; i++){
                cout << '0';
            }

            for(int i = 0 ; i < d; i++){
                cout << '9';
            }

            cout << endl;

            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }

            for(int i = 0 ; i < d; i++){
                cout << '9';
            }

            for(int i = 0 ; i < d - 1 ; i++){
                cout << '0';
            }
            cout << '1';
            cout << endl;
        }
        else{
            int d = left/9;
            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }
            for(int i = 0 ; i < d ; i++){
                cout << '0';
            }
            cout << '5';
            for(int i = 0 ; i < d ; i++){
                cout << '9';
            }
            cout << endl;

            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }
            for(int i = 0 ; i < d ; i++){
                cout << '9';
            }
            cout << '4';
            for(int i = 0 ; i < d - 1 ; i++){
                cout << '0';
            }
            cout << '1';
            cout << endl;
        }

    }

    return 0;
}


#include <iostream>

using namespace std;

int main(){
    int n ,m ;
    cin >> n >> m;

    int left = n - 5*(m-1);
    if(left <= 5){
        for(int i = 0 ; i < m ; i++){
            cout << '5';
        }
        cout << endl;
        for(int i = 0 ; i < m ; i++){
            cout << '5';
        }
        cout << endl;
    }
    else{
        int r = left%9;
        if( r > 5 ){
            int d = left/9 + 1;
            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }

            for(int i = 0 ; i < d ; i++){
                cout << '0';
            }

            for(int i = 0 ; i < d; i++){
                cout << '9';
            }

            cout << endl;

            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }

            for(int i = 0 ; i < d; i++){
                cout << '9';
            }

            for(int i = 0 ; i < d - 1 ; i++){
                cout << '0';
            }
            cout << '1';
            cout << endl;
        }
        else{
            int d = left/9;
            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }
            for(int i = 0 ; i < d ; i++){
                cout << '0';
            }
            cout << '5';
            for(int i = 0 ; i < d ; i++){
                cout << '9';
            }
            cout << endl;

            for(int i = 0 ; i < m - 1; i++){
                cout << '5';
            }
            for(int i = 0 ; i < d ; i++){
                cout << '9';
            }
            cout << '4';
            for(int i = 0 ; i < d - 1 ; i++){
                cout << '0';
            }
            cout << '1';
            cout << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   int x;
   for(int i=0;i<n;i++)
   {
      cout<<"1";
   }
   cout<<endl;
   if(m!=1)
   cout<<m-1;
   for(int i=0;i<n;i++)
   {
      if(i==n-1)cout<<"9";
      else
         cout<<"8";
   }
   cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   int x;
   for(int i=0;i<n;i++)
   {
      cout<<"1";
   }
   cout<<endl;
   cout<<m-1;
   for(int i=0;i<n;i++)
   {
      cout<<"9";
   }
   cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   int x;
   for(int i=0;i<n;i++)
   {
      cout<<"1";
   }
   cout<<endl;
   cout<<m-1;
   for(int i=0;i<n-1;i++)
   {
      cout<<"8";
   }
   cout<<"9";
   cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   int x;
   for(int i=0;i<n;i++)
   {
      cout<<"1";
   }
   cout<<endl;
   cout<<m-1;
   for(int i=0;i<n;i++)
   {
      if(i==n-1)cout<<"9";
      else
         cout<<"8";
   }
   cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   for(int i=0;i<n;i++)
   {
      cout<<"1";
   }cout<<endl;
   for(int i=0;i<m;i++)
   {
      cout<<"1";
   }cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   n=max(n,m);
   while(n>0){
      c++;
      n/=10;
   }
   cout<<"1";
   for(int i=0;i<c;i++)
   {
      cout<<"0";
   }
   cout<<endl;
   cout<<" 1";
   for(int i=0;i<c;i++)
   {
      cout<<"0";
   }
   cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   n=max(n,m);
   while(n>0){
      c++;
      n/=10;
   }
   cout<<"1";
   for(int i=0;i<c;i++)
   {
      cout<<"0";
   }
   cout<<" 1";
   for(int i=0;i<c;i++)
   {
      cout<<"0";
   }
   cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
 main()
{
   int n,m,c=0;
   cin>>n>>m;
   int x;
   x=10000*m;
   cout<<n<<endl;
   cout<<x-n<<endl;

}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;cin>>n>>m;
    string s=to_string(n);
    int x=s.size();
    for(int i=0;i<x;i++){
        cout<<n;
    }
    cout<<endl;
    for(int i=0;i<x-1;i++){
        cout<<m;
    }
    cout<<m+1;
    return 0;
}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;cin>>n>>m;
    string s=to_string(n);
    int x=s.size();
    for(int i=0;i<x;i++){
        cout<<m;
    }
    cout<<endl;
    for(int i=0;i<x-1;i++){
        cout<<m;
    }
    cout<<m+1;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<100;i++)
    {

            cout<<"5";

    }
    cout<<endl;

    for(int i=0;i<99;i++)
    {
            cout<<"4";
    }
    cout<<"5"<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;
    cout<<"1";
    for(int i=0;i<11;i++)
    {

            cout<<"0";

    }
    cout<<endl;
    cout<<"1";
    for(int i=0;i<10;i++)
    {
            cout<<"0";
    }
    cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<1000;i++)
    {
        {
            cout<<"5";
        }
    }
    cout<<endl;
    for(int i=0;i<1000;i++)
    {
            cout<<"4";
    }
    cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<1000;i++)
    {

            cout<<"5";

    }
    cout<<endl;

    for(int i=0;i<999;i++)
    {
            cout<<"4";
    }
    cout<<"5"<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<10;i++)
    {

            cout<<"5";

    }
    cout<<endl;
    for(int i=0;i<10;i++)
    {
            cout<<"4";
    }
    cout<<endl;

}


/********** I AM JOKER *********/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout<<"####"<<x<<"####"<<endl
#define MAX 400001
struct node{
	int first,second
};
node tree[MAX];
int build(int a[],int low,int high,int node)
{

	if(low==high)
	{
		tree[node].first=a[low];
		tree[node].second=INT_MIN;

	}
	else
	{
		int mid=(high+low)/2;
		tree[node].first=max(tree[2*node+1].first+tree[2*node+1].first);
		tree[node].second=min(max(tree[2*node+1].first,tree[2*node+2].second),max(tree[2*node+1].second,tree[2*node+2].second));
	}

}
int update(int a[],int low,int high,int idx,int node,int value)
{
	if(low==high)
	{
		tree[node].first=value;
		tree[node].second=min;
	}
	else
	{
		int mid=(high+low)/2;
		if(idx<=mid)
		{
			update(a,low,mid,idx,2*node+1,value);
		}
		else
		{
			update(a,mid+1,high,idx,2*node+2,value);
		}
		tree[node].first=max(tree[2*node+1].first+tree[2*node+1].first);
		tree[node].second=min(max(tree[2*node+1].first,tree[2*node+2].second),max(tree[2*node+1].second,tree[2*node+2].second));

	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	build(a,0,n-1,0);

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<400;i++)
    {

            cout<<"5";

    }
    cout<<endl;

    for(int i=0;i<500;i++)
    {
            cout<<"4";
    }
    cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;
    int b=n;
    int b1=m;
    int count=0,count1=0;
    for(int i=n;i<=2230;i++)
    {

        for(int j=i+1;j<=2230;j++)
        {
            int sum=0;
            int k=(i+j);
            while(k!=0)
            {
                sum+=k%10;
                k=k/10;
            }
            if(sum<=m)
            {
                cout<<i<<endl<<j<<endl;
                return 0;
            }

        }
    }

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;
    int b=n;
    int b1=m;
    int count=0,count1=0;
    for(int i=n;i<=2230;i++)
    {

        for(int j=i+1;j<=2230;j++)
        {
            int sum=0;
           int k=(i+j)/2;
            while(k!=0)
            {
                sum+=k%10;
                k=k/10;
            }
            if(sum<=m)
            {
                cout<<i<<endl<<j<<endl;
                return 0;
            }

        }
    }

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<2229;i++)
    {
        {
            cout<<"5";
        }
        cout<<endl;
        for(int i=0;i<2229;i++)
        {
            cout<<"4";
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<2229;i++)
    {
        {
            cout<<"5";
        }
    }
        cout<<endl;
        for(int i=0;i<2229;i++)
        {
            cout<<"4";
        }
        cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;

    for(int i=0;i<12;i++)
    {

            cout<<"5";

    }
    cout<<endl;
    for(int i=0;i<10;i++)
    {
            cout<<"4";
    }
    cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define xx 26

int main()
{

    int n,m;
    cin>>n>>m;
    int b=n;
    int b1=m;
    int count=0,count1=0;
    for(int i=n;i<=2230;i++)
    {

        for(int j=i+1;j<=2*i;j++)
        {
            int sum=0;
            int k=(i+j);
            while(k!=0)
            {
                sum+=k%10;
                k=k/10;
            }
            if(sum<=m)
            {
                cout<<i<<endl<<j<<endl;
                return 0;
            }

        }
    }

}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		int t=n/5;
		if(n%5!=0){
			t++;
		}
			for(int i=1;i<2230;i++){
				printf("5");
			}
				printf("\n");
			for(int i=1;i<2230;i++){
				printf("5");
			}
			printf("\n");
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		int t=n/5;
		if(n%5!=0){
			t++;
		}
		if(t<=m){
		for(int i=1;i<=2230;i++){
			printf("5");
		}
		printf("\n");
		for(int i=1;i<2230;i++){
			printf("4");
		}
		printf("5\n");
		}
		else{

		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		int t=n/5;
		if(n%5!=0){
			t++;
		}
		if(t<=m){
		for(int i=2230-t;i>t;i--){
			printf("9");
		}
		for(int i=1;i<=t;i++){
			printf("5");
		}
		printf("\n");
		for(int i=1;i<=t;i++){
			printf("5");
		}
		printf("\n");
		}
		else{

		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		for(int i=1;i<=2230;i++){
			printf("5");
		}
		printf("\n");
		for(int i=1;i<2230;i++){
			printf("4");
		}
		printf("5\n");
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		for(int i=1;i<=2230;i++){
			printf("5");
		}
		printf("\n");
		for(int i=1;i<2230;i++){
			printf("4");
		}
		printf("5\n");
		}
		else{

		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		int t=n/5;
		if(n%5!=0){
			t++;
		}
		for(int i=0;i<t;i++){
			printf("5");
		}
		printf("\n");
		for(int i=0;i<t;i++){
			printf("5");
		}
		printf("\n");
	}
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, 1130){
        cout << 5;
    }
    cout << '\n';
    rep(i, 1130){
        cout << 4;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, 1130){
        cout << 5;
    }
    cout << '\n';
    rep(i, 1129){
        cout << 4;
    }
    cout << 1;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n){
        cout << 1;
    }
    cout << '\n';
    rep(i, n){
        cout << 9;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    cboost;
    int n, m;
    cin >> n >> m;
    rep(i, 300){
        cout << 5;
    }
    cout << '\n';
    rep(i, 299){
        cout << 4;
    }
    cout << 5;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, 1130){
        cout << 5;
    }
    cout << '\n';
    rep(i, 1129){
        cout << 4;
    }
    cout << 6;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    cboost;
    int n, m;
    cin >> n >> m;
    rep(i, 300){
        cout << 5;
    }
    cout << '\n';
    rep(i, 299){
        cout << 4;
    }
    cout << 6;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, 2230){
        cout << 5;
    }
    cout << '\n';
    rep(i, 2229){
        cout << 4;
    }
    cout << 6;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdio>
#include <random>
#include <stack>
#include <cstdlib>
#include <numeric>
using namespace std;

#define deb(a) if (DEBUG_) {cout << a << endl;}
#define cboost cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define repf(i, f, t) for(int i = f; i < t; i++)
#define repfr(i, f, t) for(int i = f; i >= t; i--)
#define infc for(;;)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define vec vector
#define cint(n) int n; cin >> n
#define cll(n) int64_t n; cin >> n
#define cing(s) string s; cin >> s
#define cinc(c) char c; cin >> c

const int INF = 2e9;
const bool DEBUG_ = 0;
const int MOD = 1e6;
const double EPS = 1e-6;

int main(){
    int n, m;
    cin >> n >> m;
    if (n <= 9){
        return !(cout << n << ' ' << n << endl);
    }
    string s = "";
    while (n >= 9){
        n -= 9;
        s += "9";
    }
    s += to_string(n);
    cout << s << ' ' << s << endl;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pii  pair <int, int>
#define pll  pair <ll, ll>
#define plp  pair <int, pll >
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll n, m, i, j;
bool chk = true;

ll sod(ll x)
{
	ll sum = 0;
	while(x>0)
	{
		sum+=(x%10);
		x/=10;
	}
	return sum;
}

int main()
{
	cin>>n>>m;
	for(i=n;i<=2230;i++){
		for(j=n;j<=2230;j++)
		{
			if(sod(i+j)<=m)
			{
				chk = false;
				break;
			}
		}
		if(!chk)
			break;
	}
	cout << i << endl << j << endl;
	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pii  pair <int, int>
#define pll  pair <ll, ll>
#define plp  pair <int, pll >
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll n, m, i, j;

ll sod(ll x)
{
	ll sum = 0;
	while(x>0)
	{
		sum++;
		x/=10;
	}
	return sum;
}

int main()
{
	cin>>n>>m;
	ll dign = sod(n);
	string s, t;
	for(i=0;i<n;i++)
		s+='1';
	for(i=1;i<n;i++)
		t+='8';
	t+='9';
	cout << s << endl << t << endl;
	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pii  pair <int, int>
#define pll  pair <ll, ll>
#define plp  pair <int, pll >
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll n, m, i, j;
bool chk = true;

ll sod(ll x)
{
	ll sum = 0;
	while(x>0)
	{
		sum+=(x%10);
		x/=10;
	}
	return sum;
}

int main()
{
	cin>>n>>m;
	for(i=0;i<=2230;i++){
		for(j=0;j<=2230;j++)
		{
			if(sod(i)>=n && sod(j)>=n && sod(i+j)<=m)
			{
				chk = false;
				break;
			}
		}
		if(!chk)
			break;
	}
	cout << i << endl << j << endl;
	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pii  pair <int, int>
#define pll  pair <ll, ll>
#define plp  pair <int, pll >
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll n, m, i, j;

ll sod(ll x)
{
	ll sum = 0;
	while(x>0)
	{
		sum++;
		x/=10;
	}
	return sum;
}

int main()
{
	cin>>n>>m;
	// ll dign = sod(n);
	cout << n << endl << n << endl;

	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pii  pair <int, int>
#define pll  pair <ll, ll>
#define plp  pair <int, pll >
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll n, m, i, j;

ll sod(ll x)
{
	ll sum = 0;
	while(x>0)
	{
		sum++;
		x/=10;
	}
	return sum;
}

int main()
{
	cin>>n>>m;
	ll dign = sod(n), p=1;
	while(dign--)
		p*=10;
	if(n>=(p/2))
		cout << n << endl << n << endl;
	else
		cout << n << endl << p-n << endl;
	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pii  pair <int, int>
#define pll  pair <ll, ll>
#define plp  pair <int, pll >
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll n, m, i, j;

ll sod(ll x)
{
	ll sum = 0;
	while(x>0)
	{
		sum++;
		x/=10;
	}
	return sum;
}

int main()
{
	cin>>n>>m;
	ll dign = sod(n);
	string s, t;
	while(n--)
	{
		s+='1';
		t+='9';
	}
	cout << s << endl << t << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 500001;
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
void stop(){
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
struct point{
	double x, y;
};
ll gcd(ll a, ll b){ return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b){ return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
int main(){
	fast
		ll n, m;
	cin >> n >> m;
	ll s1=0, s2 = 0;
	int x1 = 0, x2 = 0;
	while (s1 + 5 < n){
		s1 += 5;
		x1++;

	}
	int l1 = 0, l2 = 0;
	l1 = (n - s1);
	s1 += (n - s1);
	while (s2 + 5 < n){
		s2 += 5;
		x2++;
	}
	l2 = (n - s2);
	s2 += (n - s2);
		for (int i = 0; i <= x1; i++)cout << 5;
		//cout << l1 << endl;
		cout << endl;
		for (int i = 0; i <= x2; i++)cout << 5;
		//cout << l2 << endl;

	stop();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 500001;
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
void stop(){
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
struct point{
	double x, y;
};
ll gcd(ll a, ll b){ return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b){ return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
int main(){
	fast
		cout << 6 << endl << 6 << endl;
	stop();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 500001;
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
void stop(){
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
struct point{
	double x, y;
};
ll gcd(ll a, ll b){ return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b){ return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
int main(){
	fast
		ll n, m;
	cin >> n >> m;
	ll s1=0, s2 = 0;
	int x1 = 0, x2 = 0;
	while (s1 + 5 < n){
		s1 += 5;
		x1++;

	}
	int l1 = 0, l2 = 0;
	l1 = (n - s1);
	s1 += (n - s1);
	while (s2 + 5 < n){
		s2 += 5;
		x2++;
	}
		for (int i = 0; i <= x1; i++)cout << 5;
		//cout << l1 << endl;
		cout << endl;
		for (int i = 0; i<x1; i++)cout << 4;
		cout << 5;

		//cout << l2 << endl;

	stop();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 500001;
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
void stop(){
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
struct point{
	double x, y;
};
ll gcd(ll a, ll b){ return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b){ return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
int main(){
	fast
for(int i=0;i<299;i++)
    cout << 4;
  cout << 5 << endl;
  for(int i=0;i<300;i++)
    cout << 5;
	stop();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 500001;
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
void stop(){
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
struct point{
	double x, y;
};
ll gcd(ll a, ll b){ return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b){ return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
int main(){
	fast
		ll n, m;
	cin >> n >> m;
	ll s1=0, s2 = 0;
	int x1 = 0, x2 = 0;
	while (s1 + 5 < n){
		s1 += 5;
		x1++;

	}
	int l1 = 0, l2 = 0;
	l1 = (n - s1);
	s1 += (n - s1);
	while (s2 + 5 < n){
		s2 += 5;
		x2++;
	}
	l2 = (n - s2);
	s2 += (n - s2);
		for (int i = 0; i < x1; i++)cout << 5;
		cout << l1 << endl;
		for (int i = 0; i < x2; i++)cout << 5;
		cout << l2 << endl;

	stop();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 500001;
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
void stop(){
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
struct point{
	double x, y;
};
ll gcd(ll a, ll b){ return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b){ return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
int main(){
	fast
		ll n, m;
	cin >> n >> m;
	ll s1=0, s2 = 0;
	int x1 = 0, x2 = 0;
	while (s1 + 5 < n){
		s1 += 5;
		x1++;

	}
	int l1 = 0, l2 = 0;
	l1 = (n - s1);
	s1 += (n - s1);
	while (s2 + 5 < n){
		s2 += 5;
		x2++;
	}
		for (int i = 0; i <= x1; i++)cout << 5;
		//cout << l1 << endl;
		cout << endl;
		n -= 5;
		int ans = (n) / 4;
		for (int i = 0; i<(ans-x1); i++)cout << 9;
		for (int i = 0; i < x2; i++)cout << 4;
		cout << 5;

		//cout << l2 << endl;

	stop();
	return 0;
}


for _ in range(int(input())):
    n = int(input())
    while (n!=1):
        if n==2:
            c=c+1
            break
        elif n%2!=0:
            n=n-1
            c=c+1

        else:
            n=2
            c=c+1

    print(c)


n = int(input())
while (n!=1):
    if n==2:
        c=c+1
        break
    elif n%2!=0:
        n=n-1
        c=c+1

    else:
        n=2
        c=c+1

print(c)


primes = []
def SieveOfEratosthenes(n):
    prime = [True for i in range(n + 1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n + 1, p):
                prime[i] = False
        p += 1
    for p in range(2, n + 1):
        if prime[p]:
            primes.append(p)
SieveOfEratosthenes(int((10**9)**(1/2))+1)
for _ in range(int(input())):
    n = int(input())
    ans = 0
    if n in primes or n==1:
        print(n-1)
        continue
    for i in primes:
        if n%i==0:
            print(i)
            break


for _ in range(int(input())):
    n = int(input())
    if n==1:
        print(0)
    elif n==2:
        print(1)
    elif n==3:
        print(2)
    elif n%2==0:
        print(2)
    else:
        print(3)


for _ in range(int(input())):
    n = int(input())
    div = []
    for i in range(2,int(n**(1/2))+1):
        if n%i==0:
            div.append(i)
            div.append(n//i)
    if len(div)==0:
        print(n-1)
        continue
    print(min(div))


for _ in range(int(input())):
    n = int(input())
    div = []
    for i in range(2,int(n**(1/2))+1):
        if n%i==0:
            div.append(i)
            div.append(n//i)
    if len(div)==0:
        print(n-1)
        continue
    lg = max(div)
    # print(div)
    print(1 + (n//lg)-1)


import math
for _ in range(int(input())):
    n=int(input())
    c=0
    for i in range(2,int(n**(1/2))+1):
        if(n%i==0):
            c=c+1
            break
    if(n==1):
        print(0)
    elif(n==2):
        print(1)
    elif(c==0):
        print(2)
    elif(n%2==0):
        print(2)
    else:
        print(3)


import math
for _ in range(int(input())):
    n=int(input())
    c=0
    if(n==1):
        print(0)
    elif(n==2):
        print(1)
    elif(n==3):
        print(2)
    elif(n%2==0):
        print(2)
    else:
        print(3)


import math
for _ in range(int(input())):
    n=int(input())
    c=0
    for i in range(2,int(n**(1/2))+1):
        if(n%i==0):
            c=c+1
            break
    if(n==1):
        print(0)
    elif(n==2):
        print(1)
    elif(c==0):
        print(2)
    else:
        print(math.ceil(n/3))


import sys
input = sys.stdin.readline

'''

'''

memo = dict()
memo[1] = 0
memo[2] = 1
memo[3] = 2

def solve(n):
    if n in memo:
        return memo[n]
    else:
        count = 0
        while n != 1:
            divided = False
            for i in range(int(n**0.5)+1, 1, -1):
                if n % i == 0:
                    n //= i
                    count += 1
                    divided = True
                    break

            if not divided:
                break
        if n > 1:
            r = count + 1 + solve(n-1)
            memo[n] = r
            return r
        else:
            memo[n] = count
            return count

t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

def solve(n):
    if n <= 3:
        return n - 1
    else:
        count = 0
        for i in range(2, int(n**0.5)+1):
            if n % i == 0:
                n //= i
                count += 1
        if n > 1:
            return count + (n - 1)
        else:
            return count
t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

def solve(n):
    if n <= 3:
        return n - 1
    else:
        count = 0
        for i in range(2, int(n**0.5)+2):
            if n % i == 0:
                n //= i
                count += 1
        if n > 1:
            return count + (n - 1)
        else:
            return count
t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

def solve(n):
    if n <= 3:
        return n - 1
    else:
        count = 0
        for i in range(int(n**0.5)+1, 1, -1):
            if n % i == 0:
                n //= i
                count += 1
                break
        if n > 1:
            return count + 1 + solve(n-1)
        else:
            return count
t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

def solve(n):
    if n <= 3:
        return n - 1
    else:
        count = 0
        for i in range(int(n**0.5)+1, 1, -1):
            if n % i == 0:
                n //= i
                count += 1
        if n > 1:
            return count + 1 + solve(n-1)
        else:
            return count
t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

memo = dict()
memo[1] = 0
memo[2] = 1
memo[3] = 2

def solve(n):
    if n in memo:
        return memo[n]
    elif n % 2 == 0:
        memo[n] = 2
        return 2
    else:
        count = 0
        while n != 1:
            divided = False
            for i in range(int(n**0.5)+1, 1, -1):
                if n % i == 0:
                    n //= i
                    count += 1
                    divided = True
                    break

            if not divided:
                break

        if n > 1:
            r = count + 1 + solve(n-1)
            memo[n] = r
            return r
        else:
            memo[n] = count
            return count

t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

def solve(n):
    if n <= 3:
        return n - 1
    else:
        count = 0
        for i in range(2, int(n**0.5)+2):
            if n % i == 0:
                n //= i
                count += 1
        if n > 1:
            return count + 1 + solve(n-1)
t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

def solve(n):
    if n <= 3:
        return n - 1
    else:
        count = 0
        for i in range(2, int(n**0.5)+2):
            if n % i == 0:
                n //= i
                count += 1
        if n > 1:
            return count + 1 + solve(n-1)
        else:
            return count
t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


import sys
input = sys.stdin.readline

'''

'''

memo = dict()
memo[1] = 0
memo[2] = 1
memo[3] = 2

def solve(n):
    if n in memo:
        return memo[n]
    elif n % 2 == 0:
        memo[n] = 2
        return 2
    else:
        r = solve(n-1) + 1
        memo[n] = r
        return r

t = int(input())
for _ in range(t):
    n = int(input())
    print(solve(n))


T = int(input())

for t in range(1,T+1):
    n = int(input())

    if n == 1:
        print(0)
    elif n == 2 or n == 3:
        print(1)
    elif n % 2 == 0:
        print(2)
    else:
        print(3)


T = int(input())

for t in range(1,T+1):
    n = int(input())

    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    elif n % 2 == 0:
        print(2)
    else:
        print(3)


T = int(input())

for t in range(1,T+1):
    n = int(input())

    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    elif n % 2 == 0 or n == 3:
        print(2)
    else:
        print(3)


import sys
input = sys.stdin.readline
print = sys.stdout.write
############ ---- Input Functions ---- ############
def a(): #for int
    return(int(input()))
def b(): #for int arr
    return(list(map(int,input().split())))

def d(): #space seperated
    return(map(int,input().split()))

"""
for printing list: print(" ".join(list(map(str,list)))+"\n")
"""

"""
for printing num : print(str(n),"\n")
"""

for _ in range(int(input())):
	n=a()
	c=0
	while n>2:
		if n%2==1:
			n=n-1
			c+=1
		else:
			n=2
			c+=1
	print(str(c+1)+"\n")


import sys
input = sys.stdin.readline
print = sys.stdout.write
############ ---- Input Functions ---- ############
def a(): #for int
    return(int(input()))
def b(): #for int arr
    return(list(map(int,input().split())))
def c():  #for string
    s = input()
def d(): #space seperated
    return(map(int,input().split()))

"""
for printing list: print(" ".join(list(map(str,list)))+"\n")
"""

"""
for printing num : print(str(n)+"\n")
"""

for _ in range(int(input())):
    num = a()
    if num==1:

        print(str(0)+"\n")
    elif num==2:
        print(str(1)+"\n")
    elif num%2==1:
        print(str(3)+"\n")
    else:
        print(str(2)+"\n")


import sys
input = sys.stdin.readline
print = sys.stdout.write
############ ---- Input Functions ---- ############
def a(): #for int
    return(int(input()))
def b(): #for int arr
    return(list(map(int,input().split())))

def d(): #space seperated
    return(map(int,input().split()))

"""
for printing list: print(" ".join(list(map(str,list)))+"\n")
"""

"""
for printing num : print(str(n),"\n")
"""

for _ in range(int(input())):
	n=a()
	c=0
	if n==1:
		print(str(0)+"\n")
		continue
	while n>2:
		if n%2==1:
			n=n-1
			c+=1
		else:
			n=2
			c+=1
	c=c+1
	print(str(c)+"\n")


import sys
input = sys.stdin.readline
print = sys.stdout.write
############ ---- Input Functions ---- ############
def a(): #for int
    return(int(input()))
def b(): #for int arr
    return(list(map(int,input().split())))
def c():  #for string
    s = input()
def d(): #space seperated
    return(map(int,input().split()))

"""
for printing list: print(" ".join(list(map(str,list)))+"\n")
"""

"""
for printing num : print(str(n)+"\n")
"""

for _ in range(int(input())):
    num = a()
    if num==1:
        print(str(0)+"\n")
    elif num%2==1:
        print(str(3)+"\n")
    else:
        print(str(2)+"\n")


import sys
input = sys.stdin.readline
print = sys.stdout.write
############ ---- Input Functions ---- ############
def a(): #for int
    return(int(input()))
def b(): #for int arr
    return(list(map(int,input().split())))
def c():  #for string
    s = input()
def d(): #space seperated
    return(map(int,input().split()))

"""
for printing list: print(" ".join(list(map(str,list)))+"\n")
"""

"""
for printing num : print(str(n)+"\n")
"""

for _ in range(int(input())):
    num = a()
    if num==1:
        print(str(1)+"\n")
    elif num%1==1:
        print(str(3)+"\n")
    else:
        print(str(2)+"\n")


import sys
input = sys.stdin.readline
print = sys.stdout.write
############ ---- Input Functions ---- ############
def a(): #for int
    return(int(input()))
def b(): #for int arr
    return(list(map(int,input().split())))
def c():  #for string
    s = input()
    return(list(s[:len(s) - 1]))
def d(): #space seperated
    return(map(int,input().split()))

"""
for printing list: print(" ".join(list(map(str,list)))+"\n")
"""

"""
for printing num : print(str(n),"\n")
"""

for _ in range(int(input())):
	n=a()
	while n>2:
		if n%2==1:
			n=n-1
			c+=1
		else:
			n=2
			c+=1
	print(str(c+1),"\n")


import sys
input = sys.stdin.readline
print = sys.stdout.write
############ ---- Input Functions ---- ############
def a(): #for int
    return(int(input()))
def b(): #for int arr
    return(list(map(int,input().split())))
def c():  #for string
    s = input()
def d(): #space seperated
    return(map(int,input().split()))

"""
for printing list: print(" ".join(list(map(str,list)))+"\n")
"""

"""
for printing num : print(str(n)+"\n")
"""

for _ in range(int(input())):
    num = a()
    if num==1:
        print(str(0)+"\n")
    elif num%1==1:
        print(str(3)+"\n")
    else:
        print(str(2)+"\n")


t = int(input())

for i in range(t):
	n = int(input().strip())
	c = 0
	while n > 1:
		l = 1
		for j in range(1,n):
			if n%j == 0:
				l = j
		if n == 2:
			c += 1
			n = 1
		elif n == 3:
			c += 1
			n = 2
		elif l!=1:
			n = n//l
			c+=1
		else:
			n = n-1
			c+=1
	print(c)


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1 or n == 2 or n == 3:
		print(n-1)
	elif n%2 == 0:
		print("2")
	else:
		print("3")


t = int(input())

for i in range(t):
	m = int(input())
	c = 0
	n = m
	for j in range(2, int(n)):
		if n%j == 0:
			l = j
	while n > 1:
		if n == 2:
			c += 1
			n = 1
		elif n == 3:
			c += 1
			n = 2
		elif n%l == 0:
			n = n/l
			c+=1
		else:
			n = n-1
			c+=1
	print(c)


t = int(input)
for _ in range(t):
    n = int(input)
    if(n>3):
        print(3)
    elif(n==3):
        print(2)
    elif(n==2):
        print(1)
    else:
        print(0)


import math

def isPrime(n) :
  # Corner cases
  if (n <= 1) :
    return False
  if (n <= 3) :
    return True

  # This is checked so that we can skip
  # middle five numbers in below loop
  if (n % 2 == 0 or n % 3 == 0) :
    return False

  i = 5
  while(i * i <= n) :
    if (n % i == 0 or n % (i + 2) == 0) :
      return False
    i = i + 6
  return True

t = int(input())
for _ in range(t):
  n = int(input())
  divisor = 1
  ans = 0
  if(n==1):
    ans = 0
  else:
    while(n):
      if(isPrime(n)):
        n = n-1
        ans = ans+1
      else:
        if(n==1):
          break
        if(n==2):
          ans = ans+1
          break
        if(n==3):
          ans = ans+2
          break
        j = 2
        while j<=int(math.sqrt(n)):
          # print(j)
          if(n%j == 0 and j!=1):
            # print("Here?")
            n = j
            ans = ans+1
            break
          j = j+1

  print(ans)


t = int(input())
for _ in range(t):
    n = int(input())
    if(n>3):
        print(3)
    elif(n==3):
        print(2)
    elif(n==2):
        print(1)
    else:
        print(0)


t = int(input())
for _ in range(t):
  n = int(input())
  if(n>3):
    if(n%2 == 0):
      print(2)
    else:
      print(3)
  else:
    print(n-1)