#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  int a[5];
  while(cin >> a[0], a[0]) {
    REP(i,4)
      cin >> a[i+1];
    int te[3] = {};
    REP(i,5)
      te[a[i]-1]++;
    int hoge=0;
    REP(i,3)
      if (te[i])
        hoge++;
    if (hoge != 2) {
      REP(i,5)
        cout << 3 << endl;
      continue;
    }
    int win = 0;
    if (!te[0])
      win = 1;
    else if (!te[1])
      win = 2;
    REP(i,5) {
      if (a[i]-1 == win)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
  }
}