#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin>>n && n!=-1){
        int t = 0;
        if(n==0){
            cout << 0 << endl;
        }else{
            while(n){
                t*=10;
                t+=n%4+1;
                n/=4;
            }
            stringstream ss;
            ss << t;
            string str = ss.str();
            reverse(str.begin(),str.end());
            rep(i,str.size())str[i]--;
            cout << str << endl;
        }
    }
}