#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;
int main(){
int m,a,b;
while(scanf("%d",&m) != EOF){
if(m == 0){
break;
}
scanf("%d%d",&a,&b);//与while中的同一行 之前有一题不同一行的加个getchar
int c = a +b;
stack<int> sta;
while (c){
sta.push(c%m);
c = c/m;
}
int m = sta.size();
for( int i = 0;i < m;i++){
printf("%d",sta.top());
sta.pop();
}
printf("\n");
}
return 0;
}