#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

map<string,string> m;

string b2f(string bin) {
  if (bin.size() % 2) bin = string("0") + bin;
  
  string ret;
  for (int i = 0; i < bin.size(); i+=2) {
    string temp = bin.substr(i, 2);
    ret += m[temp];
  }
  return ret;
}

string d2b(int a) {
  if (a == 0) return string("0");
  string s;
  while (a) {
    string b(" ");
    char c = '0' + (a % 2);
    b[0] = c;
    s += b;
    a /= 2;
  }
  reverse(s.begin(), s.end());
  return s;
}

int main() {
  const string b[4] = {"00", "01", "10", "11"};
  const string d[4] = {"0", "1", "2", "3"};
  rep (i,4) m.insert(make_pair(b[i], d[i]));

  int n;
  while (cin >> n) {
    if (n == -1) break;
    cout << b2f(d2b(n)) << endl;
  }
  return 0;
}