import java.util.*;
/*
* java中没有无符号整型,所以用long(8字节)来表示非负10进制无符号的整数
* 参考http://blog.csdn.net/gaojinshan/article/details/10102227与c语言不同
*/
public class Main {
public static void main(String [] args){
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int m = cin.nextInt();
if(m==0)
break;
long intA = cin.nextLong();//注意是long,int的话通不过
long intB = cin.nextLong();
long sum = intA + intB;
if(sum==0)//考虑0+0 的情况
System.out.println(sum);
else{
String result = recursive(sum,m);
System.out.println(result);
}
}
String str="";
String digit = "0123456789";//如果是各个进制转换的话
if(num == 0)
return "";
else{
str = recursive(num/base,base);
return str+digit.charAt((int) (num%base));
}
}
}
/*
* java中没有无符号整型,所以用long(8字节)来表示非负10进制无符号的整数
* 参考http://blog.csdn.net/gaojinshan/article/details/10102227与c语言不同
*/
public class Main {
public static void main(String [] args){
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int m = cin.nextInt();
if(m==0)
break;
long intA = cin.nextLong();//注意是long,int的话通不过
long intB = cin.nextLong();
long sum = intA + intB;
if(sum==0)//考虑0+0 的情况
System.out.println(sum);
else{
String result = recursive(sum,m);
System.out.println(result);
}
}
}
//递归实现进制转换
public static String recursive(long num,long base){String str="";
String digit = "0123456789";//如果是各个进制转换的话
digit =
"0123456789abcdef"
;这里题目base在1~10之间,所以简单了
if(num == 0)
return "";
else{
str = recursive(num/base,base);
return str+digit.charAt((int) (num%base));
}
}
}