#include<cstdio> #include<stack> using namespace std; int main(){ long long m, a, b; while (scanf("%lld %lld %lld", &m, &a, &b) != EOF){ if (a == 0 && b == 0){ printf("0"); break; } long long k = a + b; stack<int> hhh; while (k != 0){ long long w; w = k%m; hhh.push(w); k = k / m; } while (!hhh.empty()){ printf("%d", hhh.top()); hhh.pop(); } printf("\n"); } }