//2012-01十进制-六进制
#include <iostream>
using namespace std;
void func(int x)
{
char res[100];
int i = 0;
while (x)
{
int a = x % 16;
x /= 16;
if (a < 10)
{
res[i++] = a + '0';
}
else
res[i++] = a - 10 + 'A';
}
for (int j = i - 1; j >= 0; j--)
cout << res[j];
cout << endl;
}
int main()
{
int n;
while (cin >> n,n)
{
func(n);
}
return 0;
}