Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		h := make([]int, 5)
		h[0], _ = strconv.Atoi(scanner.Text())
		if h[0] == 0 {
			break
		}
		for i := 1; i <= 4; i++ {
			scanner.Scan()
			h[i], _ = strconv.Atoi(scanner.Text())
		}
		tbl := make([]bool, 3)
		aiko := false
		for _, v := range h {
			tbl[v-1] = true
		}
		if tbl[0] && tbl[1] && tbl[2] { // 全ての手があるあいこ
			aiko = true
		}
		if h[0] == h[1] && h[1] == h[2] && h[2] == h[3] && h[3] == h[4] {
			aiko = true
		}
		if aiko {
			fmt.Printf("3\n3\n3\n3\n3\n")
		} else {
			win := 0
			if !tbl[0] {
				win = 2
			}
			if !tbl[1] {
				win = 3
			}
			if !tbl[2] {
				win = 1
			}
			for i := 0; i < 5; i++ {
				if h[i] == win {
					fmt.Println(1)
				} else {
					fmt.Println(2)
				}
			}
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int num[5];
    while(cin>>num[0],num[0]){
        bool hand[4]={};
        hand[num[0]]=1;
        for(int i=1;i<5;i++){
            cin>>num[i];
            hand[num[i]]=1;
        }
        if(hand[1]&&hand[2]&&hand[3]||!hand[1]&&!hand[2]||!hand[2]&&!hand[3]||!hand[3]&&!hand[1])
            for(int i=0;i<5;i++)cout<<"3\n";
        else {
            int win;
            if(!hand[3])win=1;
            else if(!hand[1])win=2;
            else win=3;
            for(int i=0;i<5;i++){
                if(win==num[i])cout<<"1\n";
                else cout<<"2\n";
            }
        }
    }
}

C++: #include<iostream>
using namespace std;
int main()
{
	while (true){
		int a[5];
		int f[4] = { 0 };
		for (int i = 0; i < 5; i++){
			cin >> a[i];
			if (i == 0 && a[i] == 0){
				return 0;
			}
			f[a[i]]++;
		}
		if (f[1]>0 && f[2] > 0 && f[3] > 0 || f[1] > 4 || f[2] > 4 || f[3] > 4){
			for (int i = 0; i < 5; i++){
				cout << "3" << endl;
			}
		}
		else if (f[1]>0 && f[3] > 0){
			for (int i = 0; i < 5; i++){
				if (a[i] == 1){
					cout << "2" << endl;
				}
				else{
					cout << "1" << endl;
				}
			}
		}
		else if (f[2] > 0 && f[3] > 0){
			for (int i = 0; i < 5; i++){
				if (a[i] == 3){
					cout << "2" << endl;
				}
				else{
					cout << "1" << endl;
				}
			}
		}
		else{
			for (int i = 0; i < 5; i++){
				cout << a[i] << endl;
			}
		}
	}
}

C++: #include <iostream>
#include <string>

using namespace std;

int main() {    
    ios::sync_with_stdio(false);

    while(1){
      int a[5];
      int b[3]={};
      int i;
      cin >> a[0];
      if(a[0]==0)
	break;

      for(i=1;i<5;i++){
	cin >> a[i];
      }

      for(i=0;i<5;i++)
	b[a[i]-1]++;


      if((b[0]*b[1]*b[2]!=0) || (b[0]==0 && b[1]==0) || (b[1]==0 && b[2]==0) || (b[2]==0 && b[0]==0)){
	for(i=0;i<5;i++)
	  cout << 3 << endl;
      }
      
      else{
	//??°??????0
	if(b[0]==0){
	  for(i=0;i<5;i++){
	    if(a[i]==2)
	      cout << 1 << endl;
	    if(a[i]==3)
	      cout << 2 << endl;
	  }
	}

	//?????§??????0
	if(b[1]==0){
	  for(i=0;i<5;i++){
	    if(a[i]==3)
	      cout << 1 << endl;
	    if(a[i]==1)
	      cout << 2 << endl;
	  }
	}

	//?????????0
	if(b[2]==0){
	  for(i=0;i<5;i++){
	    if(a[i]==1)
	      cout << 1 << endl;
	    if(a[i]==2)
	      cout << 2 << endl;
	  }
	}
      }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
	int hand[5];
	int d[3]={2,3,1};
	while(1){
		cin >> hand[0];
		if(hand[0] == 0) break;
		int cou[4] = {0};
		cou[hand[0]]++;
		for(int i=1;i<=4;i++){
			cin >> hand[i];
			cou[hand[i]]++;
		}
		int tmp=0,temp=0;
		for(int i=1;i<=3;i++){
			if(cou[i] == 5){
				tmp = 1;
				break;
			}
			else if(cou[i] == 0){
				temp = i;
			}
		}
		for(int i=0;i<5;i++){
			if(tmp == 1 || temp == 0) cout << "3" << endl;
			else {
				if(hand[i] == d[temp-1]) cout << "1" << endl;
				else cout << "2" << endl;
			}
		}
	}
}

C++: #include<iostream>
#define G 1
#define C 2
#define P 3
#define N 5
using namespace std;

int a[N];

void calc() {

  int g,c,p;

  g=0;
  c=0;
  p=0;

  for ( int i=0; i<N; i++ ) {
    if ( a[i] == G )
      g = 1;
    if ( a[i] == C )
      c = 1;
    if ( a[i] == P )
      p = 1;
  }

  for ( int i=0; i<N; i++ ) {
    if ( g == c == p || g && c && p ) {
      cout << 3 << endl;
    } else {
      if ( g == 1 ) {
	if ( a[i] == G ) {
	  if ( c == 1 )
	    cout << 1 << endl;
	  else if ( p == 1 ) 
	    cout << 2 << endl;
	  else
	    cout << 3 << endl;
	}
	if ( a[i] == C ) {
	  cout << 2 << endl;
	}
	if ( a[i] == P ) {
	  cout << 1 << endl;
	}
      } else if ( c == 1 ) {
	if ( a[i] == G ) {
	  cout << 2 << endl;
	}
	if ( a[i] == C ) {
	  if ( g == 1 )
	    cout << 2 << endl;
	  else if ( p == 1 ) 
	    cout << 1 << endl;
	  else
	    cout << 3 << endl;
	}
	if ( a[i] == P ) {
	  cout << 1 << endl;
	}

      } else if ( p == 1 ) {
	if ( a[i] == G ) {
	  cout << 1 << endl;
	}
	if ( a[i] == C ) {
	  cout << 2 << endl;
	}
	if ( a[i] == P ) {
	  if ( g == 1 ) 
	    cout << 1 << endl;
	  else if ( c == 1 )
	    cout << 2 << endl;
	  else
	    cout << 3 << endl;
	}
      }
    }
  }
}

int main () {
  
  while ( true ) {
    bool skip = false;
    for ( int i=0; i<N; i++ ) {
      cin >> a[i];
      if ( a[i] == 0 ) {
	return 0;

      }

    }

    if ( a == 0 )
      break;

    calc();
  }
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int c[5];
    while(cin >> c[0], c[0]){
        range(i,1,5)
            cin >> c[i];
        bool rock, paper, scissors;
        rock = paper = scissors = false;
        rep(i,5){
            if(c[i] == 1){
                rock = true;
            }else if(c[i] == 2){
                scissors = true;
            }else{
                paper = true;
            }
        }
        int r, p ,s;
        if(rock && paper && scissors){
            r = p = s = 3;
        }else if(rock && paper && !scissors){
            p = 1;
            r = 2;
        }else if(rock && scissors && !paper){
            r = 1;
            s = 2;
        }else if(paper && scissors && !rock){
            s = 1;
            p = 2;
        }else if(rock){
            r = 3;
        }else if(paper){
            p  3;
        }else if(scissors){
            s = 3;
        }
        rep(i,5){
            if(c[i] == 1)
                cout << r << endl;
            else if(c[i] == 2)
                cout << s << endl;
            else if(c[i] == 3)
                cout << p << endl;
        }
    }
}

C++: #include <iostream>
using namespace std;

int main(){
	int human[5];
	while(cin>>human[0],human[0]){
		bool hand[3]={};
		for(int i=1;i<5;i++){
			cin>>human[i];
			if(human[i]==1) hand[0]++;
			else if(human[i]==2) hand[1]++;
			else hand[2]++;
		}
		if((hand[0]==true&&hand[0]==hand[1]&&hand[0]==hand[2])||(hand[0]==false&&hand[0]==hand[1]))||(hand[0]==false&&hand[0]==hand[2]))||(hand[1]==false&&hand[1]==hand[2])) for(int i=0;i<5;i++)cout<<'3'<<endl;
		else if(hand[0]==)
		else if(hand[0]==true&&hand[0]==hand[1]){
			for(int i=0;i<5;i++){
				if(human[i]==1)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
		else if(hand[0]==true&&hand[0]==hand[2]){
			for(int i=0;i<5;i++){
				if(human[i]==3)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
		else if(hand[1]==true&&hand[1]==hand[2]){
			for(int i=0;i<5;i++){
				if(human[i]==2)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
	}
	return 0;
}