#include <cstdio>

using namespace std;

int fromf(char c){
	if('0' <= c && c <= '9'){
		return c - '0';
	}else{
		return 10 + c - 'a';
	}
}

char tof(int i){
	if(i < 10){
		return '0' + i;
	}else{
		//printf("\n!!%d!!\n",i);
		return 'A' + (i - 10);
	}
}

int main(){
	int data;
	int self;
	char c[256];
	char ans[256];
	char *pt,*ptt;
	while(scanf("%d",&data) && data != -1){
		sprintf(c,"%x",data);
		ptt = ans;
		pt = c;
		while(*pt != '\0'){
			
			self = fromf(*pt);
			self /= 4;
			//printf("!%d->%d\n",self,self/4);
			*ptt = tof(self);
			ptt++;
			self = fromf(*pt) % 4;
			*ptt = tof(self);
			ptt++;
			pt++;
		}
		*ptt = '\0';
		ptt = ans;
		if(*ptt == '0'){
			ptt++;
		}
		printf("%s\n",ptt);
	}
	return 0;
}