#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int m;
    long long A, B;
    while (cin >> m) {
        if (m == 0) break;
        cin >> A;
        cin >> B;
        long long val = A + B;
        vector<int> res;
        if (val == 0) res.push_back(0);
        while (val != 0) {
            res.push_back(val % m);
            val = val / m;
        }
        for (int i = res.size()-1; i >= 0; i--) {
            cout << res[i];
        }
        cout << endl;
    }
    return 0;
}