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

int main() {
    int a,b,m;
    while(cin>>m)
    {
        if(m==0)break;
        cin>>a>>b;
//        cout<<a<<" "<<b<<" "<<m<<endl;
        vector<long long>v;
        long long c= a+b;
        if(c==0)v.push_back(c);
        while(c!=0)
        {
            v.push_back(c%m);
            c = c/m;
        }
        for(int i=v.size()-1;i>=0;i--)
        {
            cout<<v[i];
        }cout<<endl;


    }
}
// 64 位输出请用 printf("%lld")