#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a[5];
  while (scanf("%d%d%d%d%d", a, a+1, a+2, a+3, a+4) == 5) {
    bool b[3] = {0};
    for (int i = 0; i < 5; i++)
      b[a[i]-1] = true;
    if (b[0] && b[1] && b[2] ||
        b[0] && !b[1] && !b[2] ||
        !b[0] && b[1] && !b[2] ||
        !b[0] && !b[1] && b[2])
      for (int i = 0; i < 5; i++)
        cout << 3 << endl;
    else {
      int w;
      if (b[0] && b[1])
        w = 1;
      else if (b[1] && b[2])
        w = 2;
      else
        w = 3;
      for (int i = 0; i < 5; i++)
        cout << (a[i] == w ? 1 : 2) << endl;
    }
  }
  return 0;
}