# include <iostream>
using namespace std;

int br[1028];

int make(int a,int b)
{
    int n=a*b;
    //cout<<n<<endl;
    int ans=0;

    int u=1;
    for(int i=1;i<=3;i++)
    {
        int d=n%10;
        if(d==0) d=9;
        else d--;

        ans=ans+u*d;
        u=u*10;
        n=n/10;
    }

    return ans;
}

int main()
{
    int n,a,b;
    cin>>n>>a>>b;

    if(n==1)
    {
        cout<<a<<endl;
        return 0;
    }

    if(n==2)
    {
        cout<<b<<endl;
        return 0;
    }

    for(int i=3;i<=n;i++)
    {
        int c=make(a,b);
        a=b;b=c;
    }

    cout<<b<<endl;
    return 0;
}
