#include<iostream>
using namespace std;
int main() {
	int a[100], sum = 1, b = 0, n, c[100], sum2 = 1;
	while (sum <= 1000000) {
		a[b] = sum;
		c[b] = sum2;
		b++;
		sum *= 4;
		sum2 *= 10;
	}
	while (cin >> n&&n != -1) {
		sum = 0;
		for (int i = b - 1; i >= 0; i--) {
			if (n >= a[i]) {
				int d = (n - (n%a[i])) / a[i];
				n -= (a[i] * d);
				sum += (c[i] * d);
			}
		}
		cout << sum << endl;
	}
}