#include<iostream>
using namespace std;
int main()
{
    int n,a,b,prob,br1=0,br12,izv=1,br3=0,m,br=2;
    cin>>n>>a>>b;
    while(br<=n){
            izv=1;
            br3=0;
            br1=0;
        if(br>=3){

            a=b;
            b=prob%1000;

        }
       prob=a*b;
       m=prob;
       izv=1;
       while(m>0){



            if(m%10==0){

            prob+=9*izv;
        }



        if(m%10!=0){


        prob-=izv;
        }


        m/=10;

         br1++;

        izv*=10;
       }

        br++;

    }
    cout<<b;
    return 0;
}
