#include<iostream>
#include<algorithm>
using namespace std;

int cnum[3];
long long n=0;
int tnum;

int findNum(int lnum, int num, int i){
    tnum = (lnum*num)%1000;
    cnum[0]=tnum/100;
    cnum[1]=(tnum%100-tnum%10)/10;
    cnum[2]=tnum%10;
    //cout<<"rec num: "<<i<<" cnum(before maths), lnum, num, lnum*num, tnum: "<<cnum[0]<<' '<<cnum[1]<<' '<<cnum[2]*1<<' '<<lnum<<' '<<num<<' '<<lnum*num<<' '<<tnum<<endl;
    if(cnum[0]!=0){
        cnum[0]-=1;
        //cout<<"01 ";
    }else if(cnum[0]==NULL){
        cnum[0]=9;
        //cout<<"02 ";

    }

    if(cnum[1]!=0){
        cnum[1]-=1;
        //cout<<"11 ";
    }else{
        cnum[1]=9;
        //cout<<"12 ";
    }

    if(cnum[2]!=0){
        cnum[2]-=1;
        //cout<<"21 ";
    }else{
        cnum[2]=9;
        //cout<<"22 ";
    }

    if(i!=n){
        //cout<<" num, cnum(after maths): "<<num<<' '<<cnum[0]<<' '<<cnum[1]<<' '<<cnum[2]<<endl;
        findNum(num, cnum[0]*100+cnum[1]*10+cnum[2]*1, i+1);
    }else if(i==n){
        return cnum[0]*100+cnum[1]*10+cnum[2]*1;
    }
}

int main(){
    cin>>n;
    int lnum, num;
    cin>>lnum>>num;



    cout<<findNum(lnum, num, 3);
    //cout<<endl<<229890%1000;
}
