#include <iostream>
#include <algorithm>
using namespace std;
//把10进制数x转换为m进制数
void func(long long x, int m) {
if (x == 0) cout << 0 << endl;
else {
string s;
while (x) {
s += '0' + x % m;
x /= m;
}
reverse(s.begin(), s.end());
cout << s << endl;
}
}
int main() {
int m, a, b;
while (cin >> m >> a >> b && m) {
func(a + b, m);
}
return 0;
}

京公网安备 11010502036488号