//注1:unsigned int 用%u占位符接收
//注2:两个unsigned int 相加结果可能溢出,用long long 保存结果
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
vector<int> vec;
void convert(long long sum, int m) {
if (sum == 0) {
printf("0");
}
else {
while (sum > 0) {
vec.push_back(sum % m);
sum /= m;
}
for (int i = vec.size() - 1; i >= 0; i--) {
printf("%d", vec[i]);
}
}
vec.clear();
}
int main() {
unsigned int m, a, b;
while (scanf("%d%d%d",&m,&a,&b)!=EOF)
{
if (m == 0) {
return 0;
}
convert(a + b, m);
printf("\n");
}
return 0;
}