#include<cstdio>

using namespace std;

int main()
{
    long long  A,B;
    long long sum ;
    int m;
    while(scanf("%d %lld %lld",&m,&A,&B)!=EOF && m != 0)
    {
        int a[32];
        int  p = 0;
        sum = A+B;
        if(sum == 0)
        {
            printf("0\n");
        }
        else
        {
             while(sum !=0)
               {
                a[p] = sum % m;
                sum = sum / m;
                p++;
            }
        }
        for(int i = p-1;i>=0;i--)
        {
            printf("%d",a[i]);
        }

    }
}