#include <bits/stdc++.h>
using namespace std;
int br[999];
int genNext(int pr1, int pr2){
    vector<int> d;
    int z=pr1*pr2, z1=0;
    if(z==0) z1=9;
    else{
        while(z){
            int digit;
            if(z%10>0) digit=(z%10-1);
            else digit=9;
            d.push_back(digit);
            z/=10;
        }
        for(int i=d.size()-1; i>=0; i--) z1=z1*10+d[i];
    }
    return z1%1000;
}
int main(){
    int n, a, b;
    cin>>n>>a>>b;
    int i=0;
    vector<int> repeat;
    repeat.push_back(a);
    repeat.push_back(b);
    while(br[a]<2 && br[b]<2){
        if(i%2==0){
            a=genNext(a, b);
            repeat.push_back(a);
            br[a]++;
        }
        else{
            b=genNext(a, b);
            repeat.push_back(b);
            br[b]++;
        }
        i++;
    }
    bool printA=i%2;
    int j=0;
    int c;
    if(printA) c=a;
    else c=b;
    while(repeat[j]!=c) j++;
    for(int k=0; k<repeat.size(); k++) cout<<repeat[k]<<' ';
    cout<<"\n";
    if(j>=n) cout<<repeat[n-1]<<endl;
    else cout<<repeat[j+n%(repeat.size()-j)]<<"\n";
    return 0;
}
