#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main(){
  lli n;
  const int maxi = 1e5;
  while(std::cin >> n, n != -1){
    vector<int> digit(100000, 0);
    for (int i = 0; i < n; i++) {
      int p = 0;
      digit[0]++;
      while(digit[p] == 4){
        digit[p] = 0;
        digit[p + 1]++;
        p++;
      }
    }
    bool flag = true;
    for (int i = maxi - 1; i >= 0; i--) {
      if(digit[i] == 0 and flag)continue;
      flag = false;
      std::cout << digit[i];
    }
    if(flag == true)std::cout << 0 << std::endl;
    else std::cout << std::endl;
  }
    
  return 0;
}