#include<cstdio>
typedef long i64;
i64 c;
int a,b,m,t;
int res[1000];
int main()
{
int i,j;
while(scanf("%d",&m) && m)
{
scanf("%d%d",&a,&b);
c=a+b;
i=0;
if(c==0) printf("0"); //0考虑
while(c>0)
{
t=c%m;
c=c/m;
res[i++]=t;
}
for(j=i-1;j>=0;j--)
printf("%d",res[j]);
printf("\n");
}
return 0;
}