#include <iostream>
using namespace std;

const int MASK = 0x03, P = 10;

int main(){
	int n, res, pow;
	while(cin >> n, n != -1){
		res = 0;
		pow = 1;
		while(n != 0){
			int digit = n & MASK;
			res += digit * pow;
			n >>= 2;
			pow *= P;
		}
		cout << res << endl;
	}
	return 0;
}